This article describes how to create your own custom numeric R variable.
- A Displayr document.
1. From the toolbar menu, select Anything > Data > Variables > New > Custom Code > R - Text.
2. Enter your R code into the R CODE section in the object inspector on the right.
Note, your R code must return the same number of results as records in your data set.
3. Click the Calculate button to run the code and create the R variable.
By default, a new variable will be added to the top of your Data Sets tree on the left. Note, if you first select a variable in your Data Sets tree, the R variable will be added directly after that. Additionally, if you have multiple data sets in your document, you should first select the appropriate Data Sets tree you wish to add the variable to.
4. Update Name and Label as appropriate.
5. OPTIONAL: If you wish to change your variable to categorical, set Structure to Nominal. This will then use the text results as category labels.