2 My intro to R recommendations:

  • There’s a whole history/background with R, but here’s what I think is the most important thing to know: there are 2 popular dialects in R, and you should become familiar with both.
    • Base R: the base language, which can be pretty esoteric and mind-bending (but totally worth it)
    • The tidyverse: a group of R packages that simplify working in R. There are Base R champions that dislike the tidyverse, but I like it and highly recommend using the tidyverse to bridge the gap between beginner and advanced understanding of R.

My intro to R recommendations (summarized):

  1. Read through the links below before starting (at least glance through them)
  2. New to R? Kickstart your learning and career with these 6 steps! – paulvanderlaken.com (learn R)
  3. Read this: Happy Git and GitHub for the useR (workflow)
  4. Read this: Project-oriented workflow - Tidyverse (workflow)
  5. Read this: A perfect RStudio layout (Ilya Kashnitsky, 2018) (workflow)

2.1 Read this “New to R” article:

2.2 Start by setting up R:

  1. Create a directory for your R learning stuff somewhere on your computer.
  2. Download A (very) short introduction to R by Paul Torfs and Claudia Bauer
    • Read the introduction and follow the steps. It will help you install all R software on your own computer and familiarize you with the standard data types.
  3. We’ll talk about your “R Workflow” at the end of this article

2.3 Spend some time learning the basics of Base R:

  1. You got a taste of Base R in A (very) short introduction to R. Follow that with Swirl and Yarrr!
  2. Swirl - a course with 15 modules that provide mastery of the basics of R in the environment itself.
    • Open up your RStudio and enter the two lines of code below in your console window.
    • install.packages('swirl') #download swirl package
    • library(swirl) #load in swirl package
    • Swirl (webpage) will automatically start and after a couple of prompts you will be able to choose the learning course called 1: R Programming: The basics of programming in R.
  3. YaRrr! The Pirate’s Guide to R (Phillips, 2017) starting in chapter 3.
    • Start with chapter 3. It’s a fun book and will provide you with more knowledge on how to program custom functions, loops, and some basic statistical modelling techniques – the thing R was actually designed for.

2.4 Follow that by learning the tidyverse:

2.5 As you go about learning R, think about your “R workflow”" (I recommend three articles):

  1. Happy Git and GitHub for the useR (Bryan, 2018) (using git with R)
    • New Project Workflow: New project, GitHub first
      1. Create a new github repository repository
      2. Click “Clone or download” -> copy link
      3. in RStudio -> File -> New Project -> Version Control -> Git -> paste url
    • Daily Workflow:
      • Start day with the “Pull” button from the “Git” tab in RStudio (make sure you are starting with the current versions)
      • Save/Commit regularly with informative commit changes
      • Amend Commits when you make incremental saves. Do commits for separate changes.
  2. A perfect RStudio layout (Ilya Kashnitsky, 2018) (My current preferred layout)
    • Adjust in “Tools” –> “Global options” –> “Pane layout”:
      • Top Left: Source
      • Bottom Left: History (then collapse)
      • Top Right: Console
      • Bottom Right: Everything else
  3. Project-Oriented Workflow (Bryan 2017) (how to think about projects in R)
    • Organize each logical project into a folder on your computer (this is also where you put your .here, .git, and/or .Rproj files)
    • Directories:
      • Create all paths relative to the top-level directory.
      • Whenever you work on this project, launch the R process from the project’s top-level directory. If you launch R from the shell, cd to the correct folder first.
    • Write every script assuming it will be run in a fresh R process:
      • User-level setup: Do not save .RData when you quit R and don’t load .RData when you fire up R.
      • Don’t do things in your .Rprofile that affect how R code runs, such as loading a package like dplyr or ggplot or setting an option such as stringsAsFactors = FALSE.
      • Daily work habit: Restart R very often and re-run your under-development script from the top.