Setup

  1. Download the .zip file for the test project from https://github.com/krlmlr/vistransrep-proj/tree/2018-12-zhr, green button “Clone or download”.

  2. Extract the .zip file to your disk.

  3. Locate and open the file R-workshop.Rproj.

  4. Open the file 01-hello.R in the scripts directory. Run it line by line by positioning the blinking cursor (caret) in the first line and pressing Ctrl + Enter (on the Mac: Cmd + Enter). Also, run it completely (press Ctrl + Shift + Enter, on the Mac: Cmd + Shift + Enter).

  5. Open the file 02-calc.R. Run it line by line.

  6. Practice the “clean slate”: Activate the console (Ctrl + 2, on the Mac Cmd + 2), press Esc twice, click the broom in the upper right corner of the console (or press Ctrl + L, also on the Mac). Make sure that the console shows a single blue > only.

  7. Open the file 03-incomplete.R in the scripts directory. Run it completely (click the “Source” button, or press Ctrl + Shift + Enter). Can you see the problem?

    Hint: Apply the “clean slate” practiced before.

  8. From a “clean slate”, run the first line in 03-incomplete.R. How do you return to a state where R accepts your commands again?

  9. Edit the file so that it can be run completely.

  10. Open the file 04-error.R in the scripts directory. Run the first line of the script. Can you interpret the error?

    Hint: Apply the “clean slate” practiced before.

  11. Open the file 05-multiline.R. Position the blinking cursor (caret) on the second line of the script, press Ctrl + Enter (on the Mac, Cmd + Enter). Can you give an interpretation for the observed behavior?

  12. Open the file 06-premature.R. Run it line by line or completely. Can you give an interpretation for the observed behavior?

Getting help

  1. Open and run the script 07-help.R.

  2. Look up the help for the following objects and functions:
    • mpg
    • geom_boxplot()
    • near()

    Hint: Position the caret on the name you want to look up the help for, and press F1.

  3. Look up the help for the %/% operator.

    Hint: Type help("%/%") in your script and run the line with Ctrl + Enter (on the Mac, Cmd + Enter)

  4. Visit https://rdrr.io or https://rdocumentation.org, search for functions and objects from this exercise.

  5. Use the search term geom_boxplot site:tidyverse.org in a search engine.

Scripts

  1. Choose “File → New file → R script” to create a new script.

  2. Save it in the scripts directory, pick a file name (recommended: 08-new). The extension .R will be added automatically.

  3. Add code to load the tidyverse package on the first line. Save the script.

Copyright © 2019 Kirill Müller. Licensed under CC BY-NC 4.0.