Chapter 3 Using R and R Markdown

In this unit we’ll be focusing on basic stuff you’ll do each time you load up R. Things that might seem a little BLEH right now but are important to making sure R works the way you want and you get output you can look at without throwing up.

3.1 Goals

  • Creating a folder for this class

  • Setting a working directory

  • Installing R Markdown

  • Opening and using R markdown

  • Use a little inline code

  • Knit the R Markdown file

3.2 Tasks

Task 1: Setup

The first thing you need to do, if you have not done it yet, is create a folder (probably on your desktop) for this course. Name it something short yet informative.

After you create your folder you need to download all the data and shit the book uses. It is located here. It should download as a zip then save all of that stuff to the folder you just created for this class.

Task 2: Working Directory

Next we need to open up R and set the working directory. When you do this you are telling R where to look when accessing data files you want to work with or any other kinds of files you want to play with in R. It is also where things will get saved.

Do Activity 3.4 to set up the working directory

Task 3: Installing R Markdown

Complete Activity 3.4 and follow the link to R Markdown. It will basically tell you to run this code in the console. It will just have you run this code install.packages("rmarkdown") but you can check out the website and click get started if you like.

I think R Markdown also installs knitr, but if it does not then click the packages tab in the lower right quadrant of R studio. Then click install, type knitr, and download it there. You could install it the same way you did R Markdown, but this method is good to know.

Task 4: Working with R Markdown

Complete activities 3.5 to 3.11. This will take you through playing with rmarkdown a bit, making little bits of code, and knitting an rmarkdown html document….like the one you’re currently reading. It’s cool!

Ignore the code at the top of the rmarkdown pages, they are in a different coding language with it’s own rules so you know…..one step at a time.

3.2.1 Task 5: Post inline code to StackOverflow

We are not all in the same location, so I’d like us to get to know one another via the use of some inline code and a prompt.

I’d like to to use inline code to tell us your name, your degree or if you’re working towards one, if you’re employed tell us your job, tell ys something that makes you irrationally angry, and something interesting.

Below is the inline code I wrote, but I’m not including the r code I used to make it or the actual answers. Create your own paragraph and post your code and paragraph there for us to see. Use the tag “hello”, You will see my information there.