MRE:
library(tsibble)
#> Warning in system("timedatectl", intern = TRUE): running command 'timedatectl'
#> had status 1
library(tidyr)
my_tsibble <- structure(list(date = structure(c(18388, 18389, 18390, 18391,
18392, 18393), class = "Date"), new_cases = c(1444, 1401, 1327,
1083, 802, NA)), row.names = c(NA, -6L), key = structure(list(
.rows = list(1:6)), row.names = c(NA, -1L), class = c("tbl_df",
"tbl", "data.frame")), index = structure("date", ordered = TRUE), index2 = "date", interval = structure(list(
year = 0, quarter = 0, month = 0, week = 0, day = 1, hour = 0,
minute = 0, second = 0, millisecond = 0, microsecond = 0,
nanosecond = 0, unit = 0), class = "interval"), class = c("tbl_ts",
"tbl_df", "tbl", "data.frame"))
drop_na(my_tsibble)
#> # A tibble: 5 x 2
#> date new_cases
#> <date> <dbl>
#> 1 2020-05-06 1444
#> 2 2020-05-07 1401
#> 3 2020-05-08 1327
#> 4 2020-05-09 1083
#> 5 2020-05-10 802
换句话说,从 a 开始tsibble
并使用drop_na
删除最后一行,我得到了一个tibble
. 这很烦人,因为为了应用预测方法,fable
我需要my_tsibble
成为tsibble
. 如何在NA
不丢失tsibble
类型的情况下删除值?