Skip to main content Skip to navigation
CEREO ggplot

Intro to R

This week was our introduction to R lecture. This lecture was a brief overview of what R is and how to use it, with the goal of making the newer R users in our community literate in R syntax. For this session users needed to have downloaded both R and R Studio.

First we discussed what R is, along with some great resources that people can use to learn R. The first resource comes from the Software Carpentry team: The second is from one of our fellow R group members, Rachel Olsson, and is an introduction for new users designed for one of her labs, but applicable here. Make sure to download both the Lab1 Walkthrough and the Floral_diversity dataset.

The R script for our session (in .txt), along with the notes we added to it in class: IntroRScript

Simple Mapping in R

Today we discussed using the “maps” package and the “ggplot2” package to make simple maps in R.

Our test dataset is from the “rgbif” data package which makes use of publicly available data (see the “getting data” Topic). To deal with some of the georeferenced data we made use of the “dismo” package .

We made a basic map using ‘maps’:


And then took the same data and mapped it using ggplot2:


Because maps limits its field of view to the “states” basemap, whereas ggplot2 does not, we weren’t able to see this spurious detection way out in the middle of the ocean. Now that we see it, we used subset() to remove it and then made a fancy WSU themed cougar map using ggplot2:


The Script is here: simple-mapping