Surveys often contain questions where people are asked to choose one option first, then another item, and then a third item, etc (e.g., brand preferences). There are a number of different ways of analyzing such data:
- By setting the question as a Nominal - Multi question, it is possible to see the number of people to choose each item as first, second, third, etc.
- By setting a question as a Pick Any - Compact question, Q will count up the proportion of people who chose each item at least once, automatically removing any duplicates.
- If the data is stored in a format where there is one variable per item, and the data indicates what order it was chosen (i.e., its ranking), there are further methods (see How to Analyze Ranking Data).
Sometimes it is useful to display this data as a Nominal - Multi variable, but to also remove duplicates, so that the numbers add up to the numbers in a Binary-Multi (Compact) variable set. This article explains how to use data that is formatted in a Nominal-Multi format:
and remove duplicate responses so statistics match that of a Binary-Multi (Compact) variable set:
but shown with their rankings:
Requirements
- A Nominal-Multi variable set to deduplicate. Here is the data used in this example:
Please note these steps require a Displayr license.
Method
- Create a new R variable set. Hover in the Data Sources tree, click + > Custom Code > Multiple R Variables > Numeric.
-
Delete the temporary code in the R CODE box in the object inspector and paste in the following code - modified for your need:
#EDIT the variable set name below to yours put the Label in backticks
df = `Rank`
#apply the duplicated function on each row (1 below)
#transform the results to match the shape of the data
#set duplicated responses to NA (missing)
df[t(apply(df,1,duplicated))]=NA
#return final variable set
df - Select the Variable Set name in the Data Sources tree, and give it a sensible Label.
- Change Structure > Nominal-Multi.
- Drag the new Variable Set to the page to create your deduplicated table:
Next
How to Merge or NET Categories on a Nominal - Multi
How to Merge Variables into a Single Variable