这是我的代码:
library(fpp3)
library(dplyr)
my_df <- data.frame("dates" = as.Date(c("2020-03-01", "2020-03-02", "2020-03-05")),
"col_1" = c(1,2,23))
colnames(my_df) <- c("dates", "1")
i <- 1
test <- my_df %>% as_tsibble(., index=dates) %>%
fill_gaps(., as.character(i) = 1)
它会产生错误:
Error: unexpected '=' in:
"test <- my_df %>% as_tsibble(., index=dates) %>%
fill_gaps(., as.character(i) ="
我也试过
test <- my_df %>% as_tsibble(., index=dates) %>%
fill_gaps(., !!as.character(i) = 1)
test <- my_df %>% as_tsibble(., index=dates) %>%
fill_gaps(., !!quo_name(i) = 1)
但得到了同样的错误。有简单的解决方法吗?我需要让它按规定工作,我不能将数据框列名更改为非数字。