This article describes how to classify text data into different themes based on another variable, so you can classify the same exact text response differently. This typically happens when you have a variable where the respondent rated something positively or negatively and you have a text variable that explains why. People with different ratings can give the same 'why' response, but you may want to analyze those differently based on the rating. Net Promotor Score data is a common example of this. To account for the rating in the classification, you need to create a new text variable that appends the rating data to the text data as prefixes, and then classify that new variable in the text categorization tool.
This article explains how to go from a text variable without additional data appended:
To a new text variable with additional data appended as prefixes:
Requirements
- You will need a Text variable. Text variables are represented by an A next to the variable label in the Data Sources tree.
- You will need a Nominal variable. Nominal variables are represented by an icon with two radio buttons
next to the variable label in the Data Sources tree.
Method
- Hover where you want the new variable in the Data Sources tree and click the variable insertion button (+) > Custom Code > R > Text.
-
In the Code Editor, copy and paste the following code and replace the names as specified in the comments:
#this code combines categories from one variable (such as a rating) with a text resopnse #replace nominal below with the categorical variable name #replace text below with the text variable name paste0(nominal, " --- ", text) - The variable will automatically calculate when you are done editing the code, or you can click Calculate in the object inspector.
- OPTIONAL: Update the new text variable's label and name on the "General" tab to make it more descriptive.
- Classify the new text variable with additional data appended as prefixes: How to Classify Text Data into Themes.
UPCOMING WEBINAR: 10 Market Research Predictions Over the Next 4 Years