Visualizing Boston winters
You discovered in the previous chapter that a much higher percentage of flights are delayed or cancelled in Boston during the winter. It seems logical that temperature is an important factor here. Perhaps colder temperatures are associated with a higher percentage of flight delays or cancellations?
In this exercise, you'll probe the plausibility of this hypothesis by plotting temperature trends over time and generating a visual overview of Boston winters.
This exercise is part of the course
Case Study: Analyzing City Time Series Data in R
Exercise instructions
- Before plotting, check the periodicity and duration of your data using
periodicity()
. Knowing the periodicity will help you interpret your data and will come in handy as you proceed. - Use
plot.xts()
to generate a plot of mean Boston temperature (temps_xts$mean
) for the duration of your data. - Generate another plot of mean Boston temperature from November 2010 through April 2011 (inclusive).
- Use
plot.zoo()
to replicate your last plot while including the other columns in your data (in this case,min
andmax
temperature). Specifyplot.type
as"single"
to include all three lines on the same panel. Do not change the prewrittenlty
argument.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Identify the periodicity of temps_xts
# Generate a plot of mean Boston temperature for the duration of your data
plot.xts(___)
# Generate a plot of mean Boston temperature from November 2010 through April 2011
plot.xts(___["___/___"])
# Use plot.zoo to generate a single plot showing mean, max, and min temperatures during the same period
plot.zoo(___["___/___"], plot.type = "___", lty = lty)