Skip to content

Commit

Permalink
Make some edits to in-course exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
geanders committed Aug 26, 2020
1 parent 3066fde commit d43fd71
Show file tree
Hide file tree
Showing 30 changed files with 650 additions and 603 deletions.
62 changes: 49 additions & 13 deletions 01-prelim.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -1346,12 +1346,27 @@ a pdf of the lecture slides for this video.

## In-course Exercise Chapter 1

### Trying out the code in slides so far
You will take turns sharing your screens as you work through this exercise. Before you
start, open you R session and use the `sample` function, with all of your group members'
names, to randomly shuffle your names (revisit the in-course exercise in the "Course Overview"
chapter if you need a reminder).

You should do this on only one groups members computer. The order that you get from R is the
order that you should take turns sharing your screen and leading the effort on coding for
your group. When you are not sharing your screen, help out with suggestions, especially
for general directions you could take to approach a question. (There are standards for
pair programming that we'll discuss next week, and these will provide more advice on how
to productively code in a group.)

### Trying out the code in slides for first lecture videos

Have one person in your group share their screen and take the lead in typing the code
or doing the other work for this part.

To start, you'll try running some simple code in R, using examples from the video lectures for Chapter 1. Take the following steps:

1. Open an R session and find the "Console" pane.
2. Go through the slides we've covered so far. Find any examples of R
2. Go through the slides for video lectures 4 ("Function calls") and 5 ("Objects and assignments). Find any examples of R
expressions and try them out at the prompt in the console.
3. Once you've run an assignment expression, find the "Environment" pane. Check
that the object name that you assigned now appears there.
Expand Down Expand Up @@ -1382,6 +1397,8 @@ after you re-run your script. Does anything about the result surprise you?

### About the dataset

Trade the screen sharing to the next member of your group.

For the rest of today's class, you'll be using a dataset of all the guests on
*The Daily Show* when Jon Stewart was the host. This data was originally
collected by Nate Silver's website,
Expand All @@ -1395,9 +1412,9 @@ file was to add (commented) attribution information at the start of the file.

**First, check out a bit more about this data and its source:**

* Check out [the Creative Commons
license](http://creativecommons.org/licenses/by/4.0/). What are we allowed to do
with this data? What restrictions are there on using the data?
<!-- * Check out [the Creative Commons -->
<!-- license](http://creativecommons.org/licenses/by/4.0/). What are we allowed to do -->
<!-- with this data? What restrictions are there on using the data? -->
* It's often helpful to use prior knowledge to help check out or validate your
dataset. One thing we might want to know about this data is if it covers the
whole time that Jon Stewart hosted *The Daily Show*. Use Google to find out the
Expand Down Expand Up @@ -1425,13 +1442,13 @@ search GitHub repositories and code specifically by programming language, so it
can be a good way to find example R code from which to learn.
```

If you have extra time:
<!-- If you have extra time: -->

* Check out [the related
article](http://fivethirtyeight.com/datalab/every-guest-jon-stewart-ever-had-on-the-daily-show/)
on FiveThirtyEight. What are some specific questions they used this data to
answer for this article?
* Who is Nate Silver?
<!-- * Check out [the related -->
<!-- article](http://fivethirtyeight.com/datalab/every-guest-jon-stewart-ever-had-on-the-daily-show/) -->
<!-- on FiveThirtyEight. What are some specific questions they used this data to -->
<!-- answer for this article? -->
<!-- * Who is Nate Silver? -->

### Manually creating vectors

Expand Down Expand Up @@ -1485,6 +1502,12 @@ class(x = appearance_year)

### Installing and using a package

Trade the screen sharing to the next member of your group. Have the person who
was sharing their screen save their R script and send it to this person through
the Zoom chat. The new person should open this R script and use it to re-run the
last part of the analysis, so that the vectors defined in the last part of the
exercise can be used here.

The `stringr` package includes a number of functions that make it easier to work
with character strings in R. In particular, it includes functions to change the
capitalization of words in character stings. Here, you'll install and load this
Expand Down Expand Up @@ -1566,7 +1589,9 @@ str(guest_list)

Next, we will work with the whole dataset. Download the data [from
GitHub](https://github.com/geanders/RProgrammingForResearch/blob/master/data/daily_show_guests.csv)
onto your computer. In class, we created an R Project for you to use for this
onto your computer. It is **very important** for you to use [this link](https://github.com/geanders/RProgrammingForResearch/blob/master/data/daily_show_guests.csv) rather than downloading the data from the FiveThirtyEight GitHub page, because there's a small difference between the two files.

In class, we created an R Project for you to use for this
class. Put the *Daily Show* data in that directory.

**Take the following steps to get the data onto your computer**
Expand Down Expand Up @@ -1601,7 +1626,7 @@ function `read_csv` from the `readr` package.
* If you do not already have it, install the `readr` package. Then load this
package within your current R session using `library`.
* Use the `read_csv` function from the `readr` package to read the data into R
and save it as the object `daily_show`.
and save it as the object `daily_show` (see tips in the next few bullets).
* Use the help file for the `read_csv` function to figure out how this function
works. To pull that up, type `?read_csv` at the R console. Can you figure out
why it's critical to use the `skip` option and set it to 4? (We will be talking
Expand Down Expand Up @@ -1669,6 +1694,14 @@ daily_show_first10

### Checking out the data

Trade who is sharing their screen again. The new coder will need to download
the data file fresh and move it into a "data" subdirectory of the R project
created at the start of the class meeting. The previous coder should save and
share his or her's R script and send that to the new person by Zoom. The new
person should start by running that code and making sure everything's working
well on their computer.


You now have the data available in your current R session as the `daily_show`
object. You'll want to check it out to make sure it read in correctly, and also
to get a feel for the data. Throughout, you can use the help pages to figure out
Expand Down Expand Up @@ -1724,6 +1757,9 @@ how many times he was a guest and when he was on the show.

**Find out more about Nate Silver on The Daily Show**

(Don't worry if you don't make it to this sections! I've put it here for groups
that move through the rest quickly.)

* The `filter` function from the `dplyr` package can be combined with logical
statements to help you create a specific subset of data. For example, if you
only wanted data from guest visits in 1999, you could run `filter(.data =
Expand Down
Loading

0 comments on commit d43fd71

Please sign in to comment.