How to use our code in R
How to set up your computer for R
Code language versions
- R – We used v3.6.3, but all code should work in v4.0, but some checks may be needed.
Organization
- Each case study has a separate folder.
- Within case study folders, codes in different languages are simply stored together.
- Some intermediary files (csv, rds) may be saved there, too.
- Currently output is not stored here
Get R
- Download R. We used v4.0.1. aka “See things now”
- We suggest to use R Studio as editor for R codes. (There many other options, too.) You can get R Studio for free.
How to run case studies in R
-
Step 1: Set the working directory for your project.
- Option 1: [Recommended] In case you use
RStudiocreate a newRstudioproject for the case studies and load it every time you are working on the project. See the official documentation on how to create and useRstudioprojects. - Option 2: Make sure some other way that your working directory is the root folder of the case study repository.
- Option 1: [Recommended] In case you use
-
Step 2: Create an
.Renvironfile in your project folder and set the directory that contains the use case data. See more information in.Renvironfile here.- Copy (and rename to
.Renviron) the.Renviron_samplefile - Set
DATA_DIRto the absolute path of the directory that contains the use case data - If you have set up an
Rstudioproject described in Step 1. then just keep the new.Renvironfile in your project folder. If you do not useRstudioproject then make sure some other way that this.Renvironfile is processed.
- Copy (and rename to