创建合理的折线图,将平均值与实际值进行比较

时间:2016-11-12 22:46:04

标签: r

我有以下数据集

enter image description here

我想创建一个折线图,比较历史平均值与2016年月度高速公路死亡人数。我想在图形中使用ggplot。

我有多次尝试,但仍然收到错误(错误:无法找到功能" ggplot2")

ggplot(Homework_8_data, aes(x = Months)) + 

  geom_(aes(y = Ave_since_2002), colour="blue") + 

  geom_line(aes(y = X2016), colour = "grey") + 

  ylab(label="Average and actual highway fatalities") + 

  xlab(label="Months")

我需要有人帮助我理解我所犯的错误并为我纠正错误。 感谢

1 个答案:

答案 0 :(得分:1)

你必须安装ggp​​lot2:

install.packages("ggplot2")

然后加载它:

library(ggplot2)

相关问题