STOR 455 (Cunningham)

June 23, 2020

We are going to try the first three questions of Case Study 1 today. But first, we need to make sure you are set up with a nice directory to work in that saves your R work in a place that you can readily find (and a place that is regularly backed up).

1. Set your Working Directory

A. Open R-studio and type getwd() at the command line of the console. This is one of a few Unix commands that we have to learn just to put files where we want them. You probably get something like

"C:/Users/rjcunnin/Documents"

If you were to start working in R right now, any documents you produce will appear in this directory by default and there is lots of other junk there so we want a nice place to keep just our VERY important STOR 455 stuff. Whereever you are, you can make a subdirectory called “STOR 455 R Projects” using the command

dir.create("STOR 455 R Projects")

Now you can view this directory by typing dir() and you can set it as your working directory by typing

setwd("STOR 455 R Projects")

It will be fine for you to do all of your work in this directory as long as your computer is backed up regularly. If your computer is not automatically backed up regularly, you will want to back up this file EVERY DAY to Dropbox, Google Drive or something similar.

NOTE: If the above Unix commands are annoying, you can accomplish the same thing by making a new folder “STOR 455 R Projects” in the way that you usually make new folders.

There is also an easy way to set your working directory from RStudio: Click ‘Session -> Set Working Directory -> Choose Directory’ and choose the folder that you just made.

Finally, a working directory on your machine works, but it is safer and much more professional to use a working directory that is actually housed somewhere other than on your machine. I use Dropbox or Google-drive for this. Both are free as long as you don’t fill them up too much with pictures, movies, etc. One of the IA’s or I can show you how to do this but we’ll use your machine directory today.

2. Move so you are sitting next to someone

OK, that’s not possible in our current set-up, so instead, go to the Resources Tab of Sakai and select ‘Case Studies’. Then click the link called “group vs solo preference signup” and fill out the very short form there.

3. Download Case Study 1

Get Case_Study_1 and put it into your working directory and open it from R-Studio.

If you are using a PC, you might need to Ctrl-click the link instead. Which will open it in a new tab. After clicking ‘download’ in this new tab, choose ‘save file’ and NOT ‘Open with’.

4. Click ‘Knit HTML’

This will give you a readable version of the Case Study. Please recognize the awesomeness of R-Studio that lets you publish a nice HTML document from the R-Markdown file. You will master this easy process at a later date.

5. Work through Questions 1-3

I will demonstrate the very first step if necessary.

6. Submit your Work for Grading

We need to practice this. First, you need to save the R-markdown file you are using as “yourname CaseStudy1”. So mine looks like “Robin Cunningham CaseStudy1”.

Then hit ‘Knit HTML’ one more time to produce an html document with the same name. Both files will be in your working directory. All homework will be handed in on Gradescope.