The following provides general information to help data processing teams edit datasets using an R console.
You can find full documentation for the Crunch R package here. The following sections provide basic information on getting started with R, but you should also refer to the official documentation to learn more. You can also leave a comment below if anything is unclear in this article.
Logging in and setting up the Crunch R package
The following describes how to log in and find your Crunch dataset with R.
- After you install R, install R Studio.
- Set up the crunch package using the following in R Studio:
3. Run the following command to load the Crunch package in R, in order to access all the functions:
5. When prompted, enter a password.
Accessing your dataset and storing it (as "ds")
The following assumes you've already uploaded your data into Crunch (either using the web app or R). If you haven't yet uploaded your dataset, you can do so in the web app, or do so with R
Once you've logged in, as above, you can your dataset using the loadDataset() function. There are a few different ways to do this, but the simplest way is to copy the URL and put it within the function, as follows:
The loadDataset() function loads up your dataset, which is different from uploading (see below). It just brings up the data for you to work with. But you can't really do anything with it, unless you store it in a variable for later use. Crunch recommends storing it in a dataset named ds, as seen in the following example:
ds <- loadDataset("https://app.crunch.io/dataset/x6347hr845h4nhf89h323278d")
Your dataset is now ready to manipulate with R.
Uploading your dataset
As mentioned can "load up" (access) your dataset using the loadDataset() function only when your dataset has been previously uploaded in Crunch. If that's not the case, you must first upload a data file. You can do this via the web app, or using R with the newDataset() function. The simplest way to do this is to copy the folder path form your hard-drive, and then put it within the function, as follows:
newDataset("C:/Test/Demo_data.sav", name="Demo Dataset")
As mentioned above, Crunch recommends storing it in a dataset named ds, as seen in the following example:
ds <- newDataset("C:/Test/Demo_data.sav", name="Demo Dataset")