Introduction
This article describes how to go from an aggregated Date/Time variable...
...to a dynamic R variable where you can change the category labels:
Requirements
A Date/Time variable. In this example we have a date variable called StartDate which has been aggregated to 1 Quarter.
Method
1. Hover over any variable in the Data Sets tree > Plus (+) > Custom Code > R - Numeric or in the toolbar select Anything > Data > Variables > New > Custom Code > R - Numeric.
2. Update the Name and Label on the object inspector under Properties > GENERAL.
3. Paste the below under Properties > R CODE:
attr(StartDate,"QDate")
This code uses the attr function to pull the aggregated QDate label from our StartDate variable.
4. Change Properties > Structure to Nominal: Mutually exclusive categories.
5. Go to Properties > DATA VALUES > Labels and update any labels as required.
6. Press OK.
Note, when your source data updates, this variable will update accordingly and any new aggregated categories will automatically be added.
See Also
How to Work with Date Ranges Using R
How to Easily Convert Strings to Times and Dates in R with flipTime
How to Work with R in Displayr
How to Create a Custom Numeric R Variable
How to Create a Custom R Text Variable