Getting Started

  1. Install R

    The main R page is here: www.r-project.org

    To download R, choose a mirror site here: cran.r-project.org/mirrors.html

    Click on the link for your OS (Linux, Mac, or Windows). You should get the latest version (currently 3.3.1). You just need the "base" program and not any of the extras.

  2. Install RStudio

    The main RStudio page is here: www.rstudio.com

    Click the "Download RStudo" button. Choose the RStudio Desktop (Free License). Again there are installers for Linux/Mac/Windows.

  3. Install the rmarkdown package

    Open RStudio. From the Console (R command line), run the following:

    install.packages("rmarkdown")

  4. Test your installation

    In the "File" menu, choose "New File -> R Markdown..." Give the document a title and select the "HTML" option. This defaults to an example R Markdown file. Click the button "Knit HTML". You should get a formatted HTML file with example text, R code, and plot.

    Note: here is a screen shot of RStudio showing where you should find the Knit HTML button (this may look slightly different depending on your OS and RStudio version). Be sure that you have a file open with extension .Rmd, and that the line output = html_document is in the header. Otherwise, the Knit HTML button may not appear.

Using RStudio from the CADE Lab

RStudio is installed on the CADE Lab machines (these are the Linux machines with names of the form "lab1-X" and "lab2-X", where X is a number). You can go to the lab and work on the machines directly, or you can also log into them remotely. See the CADE Lab FAQ, especially the page on access using NoMachine. Once you are on a machine, here is how to use RStudio:
  1. Open a terminal window, and type

    rstudio

  2. Create a new R Markdown document and run "Knit HTML" as in Step 4 above. At this point, RStudio will ask you if it can install some necessary packages. Say "yes". This will take a few minutes (but only has to be done once).

  3. Cursor problem! You may find that the cursor in the RStudio editor window is not always in the correct location (try moving around in some text and editing to see if this happens to you). This is easy to fix by changing the font settings. Go to the menu "Tools -> Global Options ...", where you will find an option for "Appearance". Here you should select a different font and hit "Apply". Now check that the cursor appears in the right place!

Useful R Markdown Links

Useful R Code Help

You can learn all of the R you need for this class by following the code examples we do in class. These will always be posted on the schedule page. Here are some further resources to get help learning R: