Step by step to getting R installed on your computer 1. Go to the R-Project webpage (www.r-project.org) 2. Select the CRAN option under Download on the left hand side of the page: 3. On the CRAN Mirrors page, select https://cloud.r-project.org or scroll down and pick a site near you. 1
4. Select Download R... for your operating system: For Windows, page 3 For (Mac) OS X, page 7 For Linux, page 10 2
5. Select base or install R for the first time : For Windows 6. Select R-3.2.2 (most current version): 7. Save the file and then install (probably from the Downloads folder). You can do this by rightclicking on the file and selecting Run. Depending on how your Windows system is set up, ou 3
may need to run as administrator in order to install R. Accept all the default options and install the package. 8. Start R by clicking on the icon:. You will have a choice between the Rx 64 and R i38 versions of R. Assuming you have a relatively recent computer running Windows 10, choose Rx 64. You can delete the other icon from your desktop if you want. 9. (Optional Step). On Windows computers R installs in MDI (multiple document interface) mode. In this mode all of the R windows (R Console, R Editor, R Graphics, etc) are placed inside a larger window that contains the drop down menu for whichever window is currently selected. In SDI (single document interface mode) each R window is on the desktop with its own menu bar. To change to SDI, use the menu tab to select Edit GUI Preferences and in the window that opens, click SDI (MDI will be checked) at the top of the dialog box. Then click on Save (at the bottom) and Save again on the next window. Finally, click OK and OK at the warning message. 4
This will save an Rconsole file in your startup directory (probably My Documents ) so that R will use SDI when it starts. Now you have to use the menu bar to select File Exit (and then say No to saving the workspace. 10. Restart R. Notice that now the R Console opens on the desktop rather than inside the R GUI window: 5
11. When you install a package for the first time, you may get a warning that R cannot put the package in the default directory. It will ask if you want to create a personal library to store the package instead. Click yes to that dialog and the next one that asks permission to create the folder in your My Documents directory. 12. You can type commands directly into the R console, but I recommend that you open a script window (File New script) to type you commands into an R Editor window that you can save. Initially you will make many mistakes and this will make it easier to correct the command and resubmit it (Edit Run line or selection). Also you can save this file for future use with a.r extension which makes it easier to re-run a set of commands or see exactly what you did last time. 13. By default R will start in your home directory (the command getwd() will display the current directory). The command dir.create("learnr") will create a new directory and setwd("learnr") will move you to that directory. Always start R by moving into this directory so that any files you save will be saved there. When you save your script files, make sure they are saved in the correct directory. 14. When you are done working with R, the command: q() will quit R (or the Menu option File Exit). R will ask if you want to save your workspace. You should click No. If you save your workspace all of the objects you have created will be saved in a file and reloaded when you start R again. You do not want this to happen. Save objects that you create explicitly using the save() function. 15. There are several graphical user interfaces (GUI) such as R Commander and Deducer and integrated development environments (IDE) such as R Studio that are available for R. You may want to consider them as you become more proficient. 6
For Mac OS X 5. Install XQuartz first and then download the current package file. 6. Download XQuartz at https://www.xquartz.org/ and double-click on the XQuartz.pkg icon to install it: 7
7. Then download and install R. 8. Start R (from the taskbar if it shows up or using Finder). 8
9. Use File New Document to open a editing window to type your R commands. R will start in your home directory (the command getwd() will display the current directory). The command dir.create("learnr") will create a new directory and setwd("learnr") will move you to that directory. Always start R by moving into this directory so that any files you save will be saved there. When you save your script files, make sure they are saved in the correct directory. 10. When you are done working with R, the command: q() will quit R (or the Menu option File Exit). R will ask if you want to save your workspace. You should click No. If you save your workspace all of the objects you have created will be saved in a file and reloaded when you start R again. You do not want this to happen. Save objects that you create explicitly using the save() function. 11. There are several graphical user interfaces (GUI) such as R Commander and Deducer and integrated development environments (IDE) such as R Studio that are available for R. You may want to consider them as you become more proficient. 9
For Linux/Ubuntu 5. Select your Linux distribution and read the instructions. If you are using Ubuntu, follow the instructions here instead of using the package manager that comes with Ubuntu. 6. In Ubuntu you can add an entry to the sources.list file using System Settings Software & Updates. The CRAN Mirror goes in URI. Note the slash (/) after the Distribution. 10
7. Next you need to add a key so that Ubuntu knows it can trust the downloads. Open a Terminal and type: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 Assuming there are no error messages, now type into the Terminal: sudo apt-get update sudo apt-get install r-base sudo apt-get install r-base-dev 8. There will be an R icon that you can click on to start the program or open a Terminal window and run the command R. Both will run R in the Terminal window since R does not have a separate window for commands. 9. You can use a text editor such as gedit (the Edit icon) to type commands and then copy and paste them to R. This is not as convenient as in Windows or Mac OS X, but you can add a plugin to gedit that will let you add the ability to send commands directly to the terminal window. 10. By default R will start in your home directory (the command getwd() will display the current directory). The command dir.create("learnr") will create a new directory and setwd("learnr") will move you to that directory. Always start R by moving into this directory so that any files you save will be saved there. When you save your script files, make sure they are saved in the correct directory. 11. There are several graphical user interfaces (GUI) such as R Commander and Deducer and integrated development environments (IDE) such as R Studio that are available for R. Since the Linux version of R runs directly in the terminal, it may be simpler to download and install the free version of R Studio: https://www.rstudio.com/products/rstudio/download/ 11
12. Open a new script file and type your commands. Click Run on the script window to send the current command or selected commands to the console. 13. When you are done working with R, the command: q() will quit R (or the Menu option File Exit). R will ask if you want to save your workspace. You should click No. If you save your workspace all of the objects you have created will be saved in a file and reloaded when you start R again. You do not want this to happen. Save objects that you create explicitly using the save() function. 12