这是我的数据示例
# A tibble: 300 x 5
year week department_id media_tpv mediana_tpv
<dbl> <chr> <dbl> <dbl> <dbl>
1 2019 00 3 90.4 65
2 2019 00 5 194. 117.
3 2019 00 65 173. 117.
4 2019 00 93 183. 105
现在,假设我想从中构造一个tsibble::yearweek()
基于 - 的索引。我尝试将年份和星期粘贴在一起,然后将其传递给yearweek()
但无法正确解析。
输入:
df <- structure(list(year = c(2019, 2019, 2019, 2019), week = c("00",
"00", "00", "00"), department_id = c(3, 5, 65, 93), media_tpv = c(90.4,
194, 173, 183), mediana_tpv = c(65, 117, 117, 105)), row.names = c(NA,
-4L), class = c("tbl_df", "tbl", "data.frame"))