如何在R

时间:2018-02-02 12:56:58

标签: r plot ggplot2 time-series

我在R ...中是全新的,我需要绘制如下的时间序列数据:

月收入 20110101 12000 20110102 11000 20110103 10700 ................
20170111 10400 20170112 10000

我从.csv加载数据,Date存储为数字。我尝试这段代码:

情节(R $ Month,R $ revenue,type ='l')

enter image description here

任何想法如何将X上的数字转换为日期并制作更好的情节。因为这不正确。

提前谢谢!

1 个答案:

答案 0 :(得分:2)

只需转换为日期。

R$Month <- as.Date(R$Month, format = "%Y%m%d")

plot(R$Month,R$revenue,type = 'l')