开始使用免费开始使用

可视化波士顿的冬季

您在上一章发现,波士顿在冬季的航班延误或取消比例要高得多。气温很可能是一项重要因素。也许温度越低,航班延误或取消的比例就越高?

在本练习中,您将通过随时间绘制气温趋势图,生成波士顿冬季的整体可视化概览,以检验这一假设是否合理。

本练习是课程的一部分

案例研究:在 R 中分析城市时间序列数据

查看课程

练习说明

  • 作图前,请使用 periodicity() 检查数据的频率与时间跨度。了解频率有助于您解释数据,并在后续步骤中派上用场。
  • 使用 plot.xts() 绘制整个数据期间的波士顿平均气温(temps_xts$mean)。
  • 再绘制一幅图,展示 2010 年 11 月至 2011 年 4 月(含首尾两月)的波士顿平均气温。
  • 使用 plot.zoo() 复现上一幅图,但同时包含数据中的其他列(在本例中为 minmax 温度)。将 plot.type 指定为 "single",使三条折线显示在同一面板上。不要更改预写好的 lty 参数。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# 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)
编辑并运行代码