将数据框架转换为用于绘图的时间序列
我有数据框架:
year sum1
<chr> <dbl>
1 1979 4
2 1980 14
3 1981 14
4 1982 13
5 1983 6
6 1984 15
7 1985 15
8 1986 7
9 1987 10
10 1988 12
我想将其转换为时间序列以制作图。有什么想法吗?
I have the dataframe:
year sum1
<chr> <dbl>
1 1979 4
2 1980 14
3 1981 14
4 1982 13
5 1983 6
6 1984 15
7 1985 15
8 1986 7
9 1987 10
10 1988 12
and I would like to convert it to time series in order to make a plot. Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需将年份转换为数字而不是字符,
如果您想将其转换为时间序列,则
然后将其转换为动物园系列,并使用经典图形或GGPLOT2(AutoPlot)。
注意
You only need to convert the year to numeric rather than character
If you do want to convert it to a time series then convert it to a zoo series and use classic graphics or ggplot2 (autoplot).
Note
转换
as.xts
和绘图
。首先通过1月1日完成日期。 。
Convert
as.xts
andplot
. First complete the dates with January 1.Data:
我们可以使用
tsibble
软件包将数据框架转换为times系列OBEJCT:We could use
tsibble
package to transfrom dataframe to times series obejct: