Вы находитесь на странице: 1из 7

Install R, RStudio, and TeX (Mac)

9/15/16, 5:54 AM

Install R, RStudio, and TeX (Mac)


Reed College

It is important to keep R and RStudio up-to-date. While it


might be the case that you wont have any issues with older
versions, as packages are updated, you may receive
strange errors. Follow steps 1 to 5 to also upgrade R and
RStudio to new versions.
Links to specific sections:
R | RStudio | TeX | Useful R Packages | Test Installation/Create RMarkdown Document

1. Determine the version of your operating system

In this example, the version of OS X is 10.10.5. This will dictate which version of R to download in the next
step.

2. Download the appropriate version of R


Click on R for Mac OS X (https://cran.r-project.org/bin/macosx/). You will see dierent options for dierent
versions of OS X. Click on which package corresponds to your version. This will bring up the dialog to save
the file.

3. Install R
Double click on the downloaded R package (PKG file) in the folder you specified. An example is shown
below.

http://www.reed.edu/data-at-reed/software/R/r_studio.html

Page 1 of 7

Install R, RStudio, and TeX (Mac)

9/15/16, 5:54 AM

Follow the installation instructions. You do not need to open R after the completed installation. RStudio will
automatically do that after it is installed and opened.

4. Download RStudio
RStudio is currently only available for Mac OS X 10.6 or higher. Click on RStudio for Mac OS X 10.6+
(https://www.rstudio.com/products/rstudio/download/). Click on the appropriate file corresponding to Mac
OS X. This will again bring up the save file dialog.

5. Install RStudio
After your download has completed, find your version of RStudio in the folder you specified.

http://www.reed.edu/data-at-reed/software/R/r_studio.html

Page 2 of 7

Install R, RStudio, and TeX (Mac)

9/15/16, 5:54 AM

Double click on the downloaded DMG file and follow the installation instructions.

6. Download MacTeX
MacTeX installs many of the things needed to use TeX for typesetting. Click on this link to download
MacTeX: http://tug.org/cgi-bin/mactex-download/MacTeX.pkg (http://tug.org/cgi-bin/mactexdownload/MacTeX.pkg). This is a large file and may take five minutes (or more, depending on your internet
connection) to download. More information is available here: https://tug.org/mactex/mactexdownload.html (https://tug.org/mactex/mactex-download.html).

7. Install MacTeX
Find your version of MacTeX in the folder you specified.

Double click on the PKG file and follow the installation instructions. You do not need to open anything after
MacTeX is finished installing.

8. Install useful R packages in RStudio


Download the file available at startup_packages.R (startup_packages.R). This is a text (script) file
containing R commands that you will run. Double click on this downloaded file in your specified directory.
This will open the file in RStudio. Shown below is only the top left pane of the four panes in RStudio and an
example script file.

http://www.reed.edu/data-at-reed/software/R/r_studio.html

Page 3 of 7

Install R, RStudio, and TeX (Mac)

9/15/16, 5:54 AM

You now want to run all of this code to install the packages listed at the top. To do this, click on the Source
button in the upper right of the top left pane (the one that has this code in it).

You should see some red text appear in the Console tab of the bottom left panel in RStudio. The code has
downloaded the packages specified and you can now use them in your code as needed.

9. Test installation
To check that R, RStudio, and TeX have been installed correctly, we will create a sample R Markdown
document. These types of documents will give you the ability to nicely document your code, include your
code, and also the output that your code produces.
Select File > New File > R Markdown from the RStudio taskbar menu.

http://www.reed.edu/data-at-reed/software/R/r_studio.html

Page 4 of 7

Install R, RStudio, and TeX (Mac)

9/15/16, 5:54 AM

In the resulting screen, select Document on the left and select PDF as the Default Output Format. (This will
check that MacTeX was appropriately installed. You can also create HTML or Word documents by
choosing the appropriate output format here. You can also change your mind later and create any of (or all
of) the three of these formats if you so choose.)

http://www.reed.edu/data-at-reed/software/R/r_studio.html

Page 5 of 7

Install R, RStudio, and TeX (Mac)

9/15/16, 5:54 AM

This creates a basic R Markdown file with some hints as to how to do a few things using R Markdown. To
see what the resulting output looks like based on this code, click on the Knit PDF button near the top of
the pane.

http://www.reed.edu/data-at-reed/software/R/r_studio.html

Page 6 of 7

Install R, RStudio, and TeX (Mac)

9/15/16, 5:54 AM

After giving the resulting PDF a name, you should obtain a PDF similar to the one shown below. The
resulting PDF will be stored in the same directory as the Rmd (R Markdown file) you just created.

Questions
Contact Chester Ismay, Instructional Technologist for Quantitative Applications, at cismay@reed.edu
(mailto:cismay@reed.edu).

http://www.reed.edu/data-at-reed/software/R/r_studio.html

Page 7 of 7

Вам также может понравиться