1.3 R projects and file management

Open the slides in a new tab here.

Exercises

  1. Download the .R script here and the .csv file here.

  2. In your computer file browser, find your epi590r-in-class repo and create an R folder and a data folder. Within the data folder add a raw folder and a clean folder. Put the .csv file in the data/raw folder and the script in R folder. Your file structure should look like this:

    epi590r-in-class/
    ├─ epi590r-in-class.Rproj
    ├─ README.md
    ├─ R/
    │   └─ clean-data-bad.R
    ├─ data/
    │   ├─ raw/
    │   │  └─ nlsy.csv
    │   └─ clean/
  3. Return to RStudio. Look to the filepane to confirm the files are there.

  4. Look at your Git pane. What do you notice? Stage, commit, and push the changes you’ve made.

  5. Try to run the code, line-by-line, in clean-data-bad.R. What do you notice?

  6. Go to Tools > Global Options and under General, change your settings so that they match these:

  7. Close RStudio. Open it up again by opening the epi590r-in-class.Rproj file in your file browser. You should have a clean environment!

Resources