r - 从 R 中的 tibble 创建时间序列对象以生成 ggseasonplot
问题描述
我正在尝试从一年的每日时间序列数据ts
中创建一个时间序列对象。数据是一个小标题,看起来像这样:R
single
Year Month Day Simple_Assault
<chr> <chr> <chr> <int>
1 2020 01 01 6
2 2020 01 02 6
3 2020 01 05 4
4 2020 01 06 4
5 2020 01 07 1
6 2020 01 08 5
7 2020 01 09 4
8 2020 01 10 2
9 2020 01 11 5
10 2020 01 12 2
# ... with 102 more rows
ts
创建对象时出现错误。这个想法是创建一个时间序列对象以生成ggseasonplot
类似于下图所示的对象:
代码
library(tidyverse)
# Create a ts object from a tibble
data_ts = ts(data, start = 2020, end = 2020, frequency = 8)
Error in attr(data, "tsp") <- c(start, end, frequency) :
invalid time series parameters specified
# Getting an error possibly due to incorrect argument use
解决方案
推荐阅读
- laravel - Laravel 和 Nuxtjs cors 显示上传文件的问题
- javascript - JS Amcharts:如何访问 LineX tooltipHTML 适配器索引?
- microcontroller - ESP8266,连接 AP 时,请求特定 IP 或可发现主机名?
- python - 遍历行如何提高速度
- excel - Excel VBA - 打开所有 .csv 文件并使用单元格值另存为 .xlsx
- flutter - 无论设备方向如何,如何在颤动中获取屏幕尺寸
- fortran - 模块过程的名称与包含范围单元中的名称冲突
- c++ - 将`std::string`临时传递给`std::string_view`参数是否安全?
- python - python从文本文件中获取字符串并从另一个文本文件中获取serach
- java - 二叉搜索树实现问题