STAT 542 Homework 4: NOTE: The first five problems listed are required. The last problem (which is actually from Chapter 6) is extra credit. -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) } EXTRA CREDIT (Optional): -Problem 4, Chapter 6 Exercises