This document will help you complete the following steps:
If you need help, you may contact KIS at 847-467-2100 (Global Hub) or 312-503-0159 (Weiboldt) or by email at kis@kellogg.northwestern.edu. They have tested these instructions and should be able to help. Please include a screenshot of any errors you encounter.
Follow these steps to ensure that you have the latest version of R and that all other packages are up-to-date.
Visit the R website to download the latest version of R for your operating system. Assuming you already have RStudio installed, you should be able to install the latest R version on top of your existing version without needing to do anything else.
Updating R itself does not update all the packages used by R—it only updates the “base” packages within R. We want to make sure that any additional packages you have are up-to-date, too. The easiest way is using the menu in RStudio, by going to “Tools|Check for Package Updates…”, as in the figure below.
Click on the “Select All” button and then click on the “Install Updates” button. You should see output in your console window that shows R downloading and installing the necessary updates.
Note: There is a chance that you will see a prompt in blue text in the console window asking “Do you want to install from sources the package which needs compilation?” Type “no” and hit enter.
It is necessary to install LaTeX in order to create pdf files.
If you already have a version of LaTeX installed, you should skip the remainder of this section.1
If you do not have LaTeX installed, follow these instructions.
Launch RStudio and place your cursor in the console window, as in the figure.
In the console, enter the appropriate commands for your operating system:
install.packages('tinytex')
tinytex::install_tinytex()
install.packages('tinytex')
tinytex::install_tinytex(dir='~/.TinyTex') # That's a tilde, not a dash
Installation will take some time, perhaps 10 minutes. As the command executes, pay attention. Two error messages might pop up. You can click to dismiss them. When the installation completes, you have successfully installed LaTeX.
Restart RStudio before continuing to the next section.
RStudio makes project management easier. For this reason, we strongly recommend that you create a new RStudio project for each course. This will help you manage all the code and data associated with a particular course.
To create a new project in RStudio:
RStudio will create the project and open it. Information about the project is stored in the project directory in a new file called retail-analytics-assignments.Rproj. The easiest way to open the project in the future is to double click on this .Rproj file.
You should store files for each course within this project directory. When you work on these files, you should first open the project in RStudio.
You will run your first R program to make sure everything is set up properly and to automatically install some additional packages. Make sure you are connected to the Internet when you complete this step.
Open the course project in RStudio. There are two ways to do this.
Once you open the project, your RStudio window should look like this:
In the Files window on the lower right, click on the dominicks.Rmd file. Alternatively, you can open this file using File|Open File. Note the Files pane shows us that both dominicks.Rmd and dominicks_oj.xlsx are in project folder.
When you open dominicks.Rmd, you might see an RStudio window pop-up asking to “Install Required Packages”. If so, click on Yes.
Click the “knit” button, as shown in the image below. RStudio may again ask your permission to install necessary packages, and if so, allow it to do so. When it finishes installing packages, you may need to click the “knit” button a second time.
If dominicks.pdf is created and the first page looks similar, that’s it! You have compiled your first R Markdown document and all the packages are working properly. This includes the installation of the tidyverse
collection of packages, which handle data manipulation, plotting, and more. You also installed a small version of , which is a suite of programs that collectively produce PDF documents. You will never have to run any of these programs yourself. Rather, RStudio uses , behind the scenes, as needed, to create PDF documents from R Markdown documents.
If you are not connected to the Internet, you will see a message at the bottom of the first page of the PDF such as “Warning: unable to access index for repository…” Make sure you are connected and then click on the “knit” button again.
You can check if you have LaTeX installed by running this command in the RStudio console: system("pdflatex --version")
. If you see an error message, you do not have LaTeX installed.↩
Copyright © 2018 Brett Gordon and Robert McDonald. All rights reserved.