Setting up R
Installing R and RStudio
- This is the base programming language
- Downloadable from http://cran.r-project.org/
- It gives a program called R or RGui which we will never use
- Always use R from within RStudio!
- 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
- Save your scripts often!
Select the commands you want to evaluate: