STAT 542 Homework 4: NOTE: The first five problems listed are required. The last problem (which is actually from Chapter 6) is Required for Graduate Students, Extra Credit for Undergrads. -Problem 6, Chapter 6 Exercises NOTE: The data are in the 'HELPfull' data table in the 'mosaicData' package. HINT for (c): The values_from argument in the pivot_wider function can specify more than one variable; for example, something like: values_from = c(variable1, variable2) -Problem 7, Chapter 6 Exercises HINT: First create a data frame called ds1 obtained by reading in the .csv file located at: https://people.stat.sc.edu/hitchcock/prob7chap6.csv -Problem 10, Chapter 6 Exercises HINT: First select the teamID, yearID, HR and HRA columns and filter based on teamID=='CHN'. HINT: For the requested time series plot, you can mimic the plot from the Japanese reactors example in class, except with geom_line instead of geom_point. The plot in Section 7.5.2 in the book is another example you could mimic somewhat. -Problem 1, Chapter 7 Exercises -Problem 4, Chapter 7 Exercises NOTE: First, run the following code in R to create a user-defined 'count_seasons' function: # The count_seasons function takes a teamID (INCLUDING quotation marks) as its input, # and returns an integer number of seasons played for that team as its output. count_seasons <- function(x){ teamsum <- Teams %>% group_by(teamID) %>% summarise( num_seasons=n() ) %>% filter(teamID==x) ans <- teamsum$num_seasons return(ans) } Required for Graduate Students, Extra Credit for Undergrads: -Problem 4, Chapter 6 Exercises NOTE about format: For this homework, please turn in TWO files into Blackboard: The first file should be a Word document or pdf with the answers to the questions in the form of any graphs/plots requested, and any written answers or interpretations for those problems that call for writing. The second file should be a PLAIN TEXT file (.txt file) with the code that you used to create the plots, etc. for the problems. Any lines in this text file that are NOT code should start with # so that they will be treated as comments and not executed. Please do include comments in lines starting with # that describe in plain English what your code is doing!