Download this worksheet

Worksheet

Notepad

http://bit.ly/conj620-cm012

Set-up

library(tidyverse)
heart <- read_csv("http://faculty.washington.edu/kenrice/heartgraphs/nhanesmedium.csv", 
                  na = ".") 

Data Dictionary

From the data dictionary:

1. How many rows and columns are in the heart data?

# your code here

2. Use dplyr to answer these questions:

# your code here

If this was easy: there are actually (at least) 4 ways to do this with dplyr functions. Try to figure out four ways to do this!

3. Use dplyr to do the following:

# your code here

4. Use ggplot2 to make a scatterplot with age in years on the x-axis and systolic blood pressure on the y-axis.

# your code here

If this was easy: import the larger dataset (http://faculty.washington.edu/kenrice/heartgraphs/nhaneslarge.csv) and make a hexagonal heatmap of 2d bin counts. Apply a custom continuous color palette to the hexbins, and reverse the colors such that lighter colors are for lower counts and darker colors are for higher counts.

5. Use dplyr and ggplot2 to do the following:

# your case_when code here
# your plot code here

If this was easy, add linear regression lines to all six facetted grids (keep the standard error ribbons). Apply a custom color palette and remove the color legend guide. Play with alpha levels for the points. Use something other than the default theme_gray().

6. Knit to html

very important: delete the text below in order to be able to knit (you won’t have the image file in your directory)