-1
A
回答
1
随着tidyr
和zoo
,这个只需要几个步骤。如果你也加载dplyr
,你可以管它。假设你的表格被称为df
...
library(dplyr)
library(tidyr)
library(zoo)
df %>%
# use tidyr to convert the wide data to long
gather(key = month, value = value, -Year) %>%
# use zoo to create a year-month index
mutate(yearmon = as.yearmon(paste(month, Year))) %>%
# now make a zoo object of the values with that index
with(., zoo(value, order.by = yearmon))
相关问题
- 1. 将数据帧转换为R中的时间序列
- 2. 如何将宽时间序列数据帧转换为长数据帧?
- 3. 将数据帧转换为时间序列
- 4. 如何将数据帧转换为时间序列
- 5. 如何将数据帧转换为时间序列
- 6. 将数据帧转换为月度时间序列
- 7. 如何将数据帧转换为时间序列
- 8. 使用R将数据帧转换为时间序列
- 9. 如何将以下时间格式转换为纪元时间
- 10. 将数据帧中的小时,分钟转换为时间格式
- 11. 我希望将以下数据帧转换为列表
- 12. 将整数转换为时间格式
- 13. 将整数转换为时间格式
- 14. 将数据时间格式转换为采样时间
- 15. 想要遍历数据帧并将时间转换为可读的R格式
- 16. 程序将时间以秒为单位转换为hh:mm:ss格式
- 17. 如何将数据帧的日期和时间列转换为熊猫的日期时间格式?
- 18. 需要将以下字符串转换为时间格式
- 19. 转换在数据帧中的列表中的所有列,以时间序列
- 20. 将数据帧转换为R中的单变量时间序列?
- 21. 将数据帧行转换为新的数据帧列R
- 22. 将Pandas列转换为数据帧
- 23. 将以下数据转换为python中的JSON格式
- 24. 转换数据帧到时间序列在30分钟间隔
- 25. 将时间序列转换为数据帧,以便每一行具有连续的时间片
- 26. 使用R将数据转换为时间序列数据
- 27. 将季度时间序列数据转换为月度数据
- 28. 将数字格式转换为matlab中的时间格式
- 29. 如何将数据帧转换为JSON格式中的R
- 30. 将数据帧转换为特定格式的频率表