Calculate Numeric Variables
This article is part of The Definitive Guide to Importing and Preparing Data.
There may be a situation where you need to calculate a numeric variable based on other variables for your analysis, such as the following use cases.
- Calculate respondents' age from their date of birth
- Calculating the difference between two variables
- Sum or average several numeric variables
In the web app
- Calculating numeric variables is not currently available in the web app.
Crunch Automation
Using R
- You can write the expression that you would like to calculate and store it as a new variable in the dataset, such as the following examples.
ds$sum <- var1 + var2 + var3
ds$average <- (var1 + var2 + var3) / 3
ds$difference <- var2 - var1