R Data Sets
How to use R to add data sets
- File > Data Sets > Add to Project > From R.
- Enter code for creating a Data Set into the R Code box. In the example below, an SPSS data file is being read in using the R function read.spss from the foreign package.
- Press F5. This will generate a preview of the Data Set's contents.
- Enter a Name (at the bottom of the screen).
- Press Add Data Set. Q will then take you through the normal process for setting up data, as if you had imported a data file.
When to use R Data Sets
In general, R Data Sets should not be used for importing data files that can be imported into Q via File > Data Sets > Add to Project > From File, as doing so will bypass a host of tools designed to check and correct problems in data.
The main use cases for R Data Sets are:
- Importing unusual types of data (e.g., web-scraping).
- Manipulating data prior to creating a data file (e.g., merging lots of data files).
- Having data sets that automatically update in dashboards (see Automatically Updating R DataSets, Variables, and Outputs).