2 Installing R and RStudio
Both R and RStudio needs to be installed on your computer. They are two separate installations, meaning that in the end, you will have one program called “R” and one program called “RStudio”. Since we always work in RStudio, this is the program you open when you want to code in R.
2.1 R
- Open an internet browser and go to www.r-project.org
- Click the “download R” link in the middle of the page under “Getting Started”.
- Select a CRAN location (a mirror site) and click the corresponding link. If you live in Norway, you should go to “Norway” and click on the link.
- Click the “Download R” for the corresponding operating system for your computer (Windows, Mac, Linux). If you have an old Mac, you need to read the next page carefully.
- Click on the “install R for the first time” link at the top of the page (Windows). Mac users have to choose the version of R that is suitable for their software system. Old Macbook-users need to make sure that they click on the link corresponding to their software. If you are unsure about your software, click the apple in the left hand corner and go to “about this Mac”. It will show MacOS followed by the name of the software.
- When having clicked the “Download R” for the corresponding operating system, save the executable file somewhere on your computer. Run the .exe file and follow the installation instructions.
- Now that R is installed, you need to download and install RStudio.
2.2 RStudio
- Go to www.rstudio.com and click on the “Download RStudio” button.
- Click on the “Download RStudio Desktop”.
- Click on the version recommended for your system and save the executable file. Run the .exe file and follow the installation instructions.
2.2.1 How RStudio works
If you open RStudio after installation, you will see the window we work in. In general, RStudio is divided into four panes, the Source pane (where we write scripts), the R Console pane (where the output of the code is displayed), the Environment pane (where all objects stored in the temporary memory are), and the pane with plots, files, packages and help (plus a few other things). If you do not have four panes when you first open RStudio, fret not, we will get to that in the next part.