(from Guide to R For SCU Economics Students Version 2.2, March 28, 2014 © William A. Sundstrom, 2012, 2013, 2014 licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported license: http://creativecommons.org/licenses/by-nc-sa/3.0/)
To get started, you need to download and install two different free software packages: R, and RStudio. You will actually be interacting with RStudio, even though R does all the number crunching. Links to the web sites for downloads are provided here and on the ECON 41/42 course page on Canvas (Camino).
R is maintained by CRAN, the “Comprehensive R Archive Network.” CRAN is a collection of sites that carry identical material, including downloads of R, extensions, documentation, and other R related files. R is available for many platforms, and below are download instructions for Mac and Windows.
- To download R, visit the website www.R-project.org (you can link from Canvas). There is a space on the website titled “Getting Started”. In it, click on the link that says “download R”.
- Next, you will be asked to choose a CRAN “Mirror” from a long list. A mirror is a server that maintains everything R related. It does not matter which one you pick.
- After arriving at the download page, click on the link corresponding to the operating system that you will be using to run R—for most of you, that’s Mac OS X or Windows.
- Follow the instructions on the next screen:
Basically, if you are running Mac OS X release 10.6 or higher, click on the link to the latest version of R. If you are running an older version of Mac OS, read the instructions and download the correct version of R.
After the install package has been downloaded, find it (probably in your Downloads folder) and double click. Let Installer walk you through installation. No customization is necessary. After installation is done, R is now on your system.
Click the link that says “install R for the first time”. On the next screen, click the link to download R for Windows.
After downloading the install package, which probably can be found in your Downloads folder, double click it and follow the installer’s instructions. Typically nothing needs to be done other than clicking either ‘next’ or ‘I Agree’ every time, accepting the default settings.
- Mac and Windows users: Now that you have installed R, you could access and run it by clicking on the icon that should now be on your desktop or among your programs. But as mentioned above, we will be interacting with R through the RStudio interface, so let’s install that now.
2. Install RStudio
Now that you have R installed on your machine, let’s download and install RStudio, which provides a more user-friendly interface and script editor for working with R. Downloading is similar for Mac and Windows.
- Visit www.Rstudio.com
- Click the “Download now” button at the bottom left.
- On the next page, click on the “Download RStudio Desktop” button.
- On the next screen, you should find your correct system under the label that says ‘Recommended For Your System’. Click that link. If it does not recommend your correct system, find it in the list and click the link.
- After the download, go into your Downloads folder and double click on the downloaded package to install.
- If you have an older Mac (running OS X 10.5), please see the professor: You may need to install a different version of RStudio.
3. Create a working directory (folder)
You will need to have all your scripts and data in a single working directory (folder). You should create this new folder in whatever folder you use for course work. Once you create the working directory, you will need to know its full “path” name. For example, on my Mac it might be: /Users/mkevane/Documents/Courses/econ_135
You can find the full path using Finder on a Mac or Explorer in Windows.