Setting up R

Installing R and RStudio

RStudio panes

  • RStudio has 4 panes:
    • Console This is the actual R window, you can enter commands here and execute them by pressing enter
    • Source This is where we can edit scripts. It is where you should always be working. Control-enter sends selected codes to the console
    • Plots/Help This is where plots and help pages will be shown
    • Workspace Shows which objects you currently have
  • Anything following a # symbol is treated as a comment!

To change the layout of panes in RStudio, go to Tools -> Global Options -> Pane Layout. Make sure you set it like this:

Creating a new script

Create a script using file -> New File -> R script:

Save the script using file -> Save as:

  • Save scripts with the extension .R.
  • Save your scripts often!
    • control+S

Running commands

Select the commands you want to evaluate: