Homework 4

Enter your name and EID here

This homework is due on Feb. 17, 2020 at 12:00pm. Please submit as a PDF file on Canvas.

Problem 1a: (3 pts) The following two data tables contain information about the hair and eye colors of male and female statistics students. Make these dataframes tidy and then combine them into a single dataframe using pivot_wider() and bind_rows().

Hint: Before combining the dataframes, make sure to mutate() a new column specifying whether the students are male or female. Two dataframes can be combined with bind_rows() as long as the column names are identical and contain the same types of data.

female <- read_csv("http://wilkelab.org/classes/SDS348/data_sets/female_haireyecolor.csv")
## Parsed with column specification:
## cols(
##   Hair = col_character(),
##   Brown = col_double(),
##   Blue = col_double(),
##   Hazel = col_double(),
##   Green = col_double()
## )
male <- read_csv("http://wilkelab.org/classes/SDS348/data_sets/male_haireyecolor.csv")
## Parsed with column specification:
## cols(
##   Hair = col_character(),
##   Brown = col_double(),
##   Blue = col_double(),
##   Hazel = col_double(),
##   Green = col_double()
## )
# Your R code here

Problem 1b: (1 pts) Using the data-frame you created above, compute the total number of students for each hair color (i.e., the sum of students that have brown, black, blond or red hair). How many students have each color of hair?

# Your R code here

Your answer here.

Problem 2: (3 pts) The chickwts dataset contains information on the weight of chicks after being fed different feed supplements. The different feed supplements are labeled casein, horsebean, linseed, meatmeal, soybean, and sunflower in the feed column. I have created a new data-frame (feed_names), that contains the abbreviated names of different feed supplements. Using one of the dplyr join functions, combine the two data-frames so that there is an additional feed_abbr column and all of the original columns and rows in chickwts are retained. Which join function is most appropriate to use and why?

head(chickwts)
##   weight      feed
## 1    179 horsebean
## 2    160 horsebean
## 3    136 horsebean
## 4    227 horsebean
## 5    217 horsebean
## 6    168 horsebean
feed_names <- read_csv("http://wilkelab.org/classes/SDS348/data_sets/feed_names.csv")
## Parsed with column specification:
## cols(
##   feed = col_character(),
##   feed_abbr = col_character()
## )
# Your R code here

Your answer here.

Problem 3: (3 pts) Recall the flights dataset from lab 3 worksheet. Ask a conceptual question about the flights dataset. Your question should not repeat the questions from class materials. Describe in 1-2 sentences how you would answer this question with an analysis or a graph.

State your question.

State your approach.