Search for question
Question

1. Shipments of Household Appliances: Line Graphs. The file ApplianceShipments.csv contains the

series of quarterly shipments (in millions of dollars) of US household appliances between 1985 and 1989.

a. Create a well-formatted time plot of the data using the ggplot2 package. Add a smoothed line

to the graph. For a closer view of the patterns, zoom in to the range of 3500-5000 on the y-

axis. Hint: in order to convert Quarter into a date format, use the zoo library's as.Date utility:

as.Date (as. yearqtr (appship.df$Quarter,format="Q%q-%Y")).

b. Does there appear to be a quarterly pattern?

c. Using ggplot2 in R, create one chart with four separate lines, one line for each of Q1, Q2, Q3, and

Q4. In R, this can be achieved by generating a data.frame for each quarter Q1, Q2, Q3, Q4 (use

seq(1,20,4), seq (2,20,4), etc. to create indexes for different quarters), and then plotting them as

separate series on the line graph. Does there appear to be a difference between quarters? Hint: For

ggplot() to display the legend, the color aesthetics must be included inside the aes() specification.

d. Using ggplot2, create a chart with one line of average shipments in each quarter. Hint: Use the

quarter () command of the lubridate package to create a new column in the shipments data frame

and use tapply to average shipments across quarters.

e. Using ggplot2, create a line graph of the series at a yearly aggregated level (i.e., the total shipments in

each year) and comment on what happened to shipments over years. Hint: Use the year() function of

the lubridate package to extract the years the shipments data frame.