I have met a problem that when I run as_tsibble() function the type of object does not change.
My primary data includes two varables, date (like 2019-01-01) and numbers of visitors. There is no missing value and each day only has one observation.
Before these records do work, however, when I am trying to make the bookdown it returns error.
Error in UseMethod("index_by") :
There is no method to apply "index_by" for "data.frame" object.
I suppose the problem is caused by the "as_tsibble" function. Because I check the class of "data_tsb", it only returns "data.frame". However, there is no error message when running the "as_tsibble" code.
I can't find how to solve the problem, and I haven't found any simmilar questions.
Can you please help? Thank you!
# remove duplicates and NA data_wd <- primary_data %>% dplyr::distinct(.) %>% na.omit() #convert to tsibble data_tsb <- data_wd %>% as_tsibble(index = date, regular= FALSE) #regularise the tsibble as daily visit_daily <- data_tsb %>% index_by(visit_date = lubridate::floor_date(date, "1 days")) %>% summarise(attendance=sum(visit)) %>% fill_gaps(attendance=0) %>% ungroup()