We will be using a set of tutorials that run in R as an aide. To run them you need to install several packages (packages are addons for R that allow us to do things that base R does not). If you want to understand the details of what we are doing I’ve written an explanation below the steps.
- Have R and RStudio installed.
- Open RStudio. On the leftside there will be a box called “R Console” you will type everything I tell you to in there.
- In the console type the below line and hit enter. This will install a package called
- Some text should popup that ends with “The downloaded binary packages are in” followed by a long file path. You might also get some red text that says “WARNING: Rtools…” this is not an important warning. If anything says “Error” contact me.
- Now type the below line and hit enter to install
POL306which has all the tutorials in it
- You will see more text again, although tis time there will be a lot more. Generally, as long as there is no red text it should be fine.
- Run one last line to check to make sure everything worked. You should see a message welcoming you to the tutorial, if you see “Error in library(POL306) : there is no package called ‘kevin’” then contact me.
- Close and reopen RStudio, you should have a Tutorial tab in the top right, click on it. It should list Introduction to R as the first tutorial. If not, contact me.
What are we doing here?
I wrote our tutorials into an R package, and have it available for anyone on Github. Github is used to share code and programs (as well as to develop them with a community). You can install a package from Github, but not natively in R. Instead we need the
remotes package, which has a function called
install_github(). So what we do is install remotes (
install.packages('remotes')) then access the
install_github() function from it to install my package (
remotes::install_github('reuning/POL306')). Finally we load the
POL306 package by calling
library(POl306). We do not need to do this, but I wrote it so that if it loads successfully you will get a nice little message.