There are some limitations to using Date/Time variables in Displayr.
- It's not possible to specify column comparisons using date variables.
- It's also not possible to have irregular dates (e.g., one column representing a year, a second column representing a quarter).
- You cannot create filters for each time period.
However, these can be achieved by creating an ordinal (or nominal) variable from the date variable.
Requirements
- Familiarity with the Structure and Value Attributes of Variable Sets.
Method - Create categories based on the date aggregation
- Select the date/time variable from Data Sources.
- Press Date/Time in the object inspector and modify the settings. For example, if you want to create months and quarters, you would set Aggregation to 1 Month.
- Press OK.
- Hover where you wish to insert the new variable into the data set and press + > Custom Code > R > Nominal.
- In the code editor at the top paste in the following code and change
date_var
to the name of your Date/Time variable :attr(date_var,"QDate")
Method - Create categories for each underlying date in the data
If you have only a few different dates, the simplest approach is to click on the date/time variable and change its Structure to Ordinal. This will create a new category for every unique date/time value. Often this leads to too many categories to be useful though and so Method 2 is preferred.
Additional Notes
After you create your new categorical variable:
- You can specify which columns to be tested, see How to Specify Columns to be Compared in a Table.
- You can create a table and Combine and Create NET across categories create any irregular dates.
- You can use the Filter > Filters from Selected Data automation to create a filter for each time period category.