GEOG 586
Geographic Information Analysis

Project 5: Getting Started in RStudio/RMarkdown


You should already have installed R and RStudio from earlier lessons.  As we discussed in Lab 2, there are two ways to enter code in R.  Most of you have likely been working in R-scripts where the code and results run in the console.  R-Markdown is another way to run code, where you essentially make an interactive report which includes "mini consoles" called code chunks.  When you run each of these, then the code runs below each chunk, so you can intersperse your analysis within your report itself.  For more details on R Markdown:

For this lab, you can choose to use either an R-script or an R-Markdown document to complete this exercise, in whichever environment you are more comfortable.

The symbols to denote a code chunk are ```{r} and ``` :

```{r setup, include=FALSE}
#code goes here
y <- 1+1

So if you are running this in a traditional R script, in these instructions, completely ignore any variant of lines containing ```{r} and ``` . 

Let's get started!

  • Start RStudio.
  • Start a new RMarkdown file.

You learned in Lesson 2 that you should set your working directory and install the needed packages in the first chunk of the RMarkdown file. Although you can do this in the Files and Packages tab in the lower right-hand corner of the Studio environment, you can hard-code these items in a chunk as follows:

### Set the Working Directory and Install Needed Packages

```{r setup, include=FALSE}

# Sets the local working directory location where you downloaded and saved the Ohio poverty dataset.

# Install the needed packages
install.packages("car", repos = "")

install.packages("corrplot", repos = "")

install.packages("ggplot2", repos = "")

install.packages("pastecs", repos = "")

install.packages("psych", repos = "")

install.packages("QuantPsyc", repos = "")