This article is part of The Definitive Guide to Importing and Preparing Data.
You may have a desire to consolidate the categories of a variable into new groups. For example, you have a categorical variable representing "Country" with 50 different countries as the categories and would like to create a new variable that represents "Continent." The process of combining responses creates a new variable.
The use case here is slightly different from creating a subtotal or a summary variable from a categorical array.
- A subtotal appears as an additional category on the same variable, in bold in the web app.
- A summary variable from a categorical array (such as a top 2 box) derives a new multiple response variable, as you are collapsing across multiple variables at once.
In the web app
There are two methods available in the web app for combining variable categories:
- When in the variable summary view, you can hover over a variable's tile and click the Properties link at the bottom left under the tile. There is a button on the right side of the panel that either says "Combine categories" or "Combine responses".
- Click the + New variable button on the bottom left of the screen under the Variable Sidebar and choose "Combine Categories" from that menu. On the following screen, select the variable whose categories you would like to combine from the sidebar.
Using either method, once the variable is selected, you will see the original categories on the left, and on the right side, you can drag the categories that you want combined in the new variable. Clicking on the combined name allows you to type a name for the new category.
Note: See Combining categories for more details.
Crunch Automation
Using R
- combine()
- collapseCategories() - Use this to combine responses in the original variable without creating a new variable.