A variable set is a grouping of one or more related variables. It may consist of a single variable (e.g., a variable measuring the age of people in a Data Set), or it may consist of multiple related variables (e.g., the age of people within a household, where there is one variable for each person).
The variable sets in a Data Set are shown in the Data Sources tree in Displayr and in the Variables and Questions tab in Q.
A variable refers to the data contained within a single column in the Data tab in Q or Data Editor in Displayr, and equivalently, an item in the Data Sources tree in Displayr, and the Variables and Questions tab in Q.
Properties
A Variable Set has the following properties:
- Variable Set Name
- A set of variables that are in the variable set. Note that while a variable can only appear once in a variable set, it can be copied multiple times so this restriction is more of an organizing principle than a constraint.
- Variable Set Structures & Question Types in Displayr and Q, respectively
- In Q, each variable has a Variable Type.
- Value Attributes
- Data Reduction
Purpose
A variable set has a number of roles:
- It is a way of organizing data.
- It expedites selection and referencing of data with code. For example, if a variable set consists of 100 variables, they can be collectively referred to by their Variable Set Name.
- It determines how variables are used when constructing tables and their associated statistical tests (see Table). See Variable Set Structure for more information.
Setting and modifying
Variable Sets are inferred when importing data into Displayr and Q. They are modified using the options in the Object Inspector and by using the options in the toolbar in Displayr, or via the Variables and Questions tab, including right-clicking on the variable set.
If Displayr AI is enabled, a sensible variable set name will be created. Otherwise, matching text will become the set name, see here for more details. You can also have Displayr use this AI naming capability across all variables by checking Use Displayr AI to tidy variable set names when you import the data.
You can see an example below. The variable set name q2 on the left was originally used due to the label pattern matching whereas the Displayr AI variable set name on the right is much more descriptive: