加载所需的库: library(dplyr) library(tsibble) library(plotly) 引入一组辅助函数,其中包括网格搜索函数 piecewise_regression ca_natural_gas_consumers.csv" ts <- read.csv(path) |> arrange(index) |> filter(index > 1986) |> as_tsibble (index = "index") ts |> head() 序列为年度数据,index 列是时间戳,y 列是数值: # A tsibble: 6 x 2 [1Y] index
library(tidyverse) library(stringr) library(janitor) library(tsibble) library(ggtext) library(bsts)
tidyquant) library(tsfeatures) library(rsample) library(purrr) library(stringr) library(tibbletime) # tsibble from = start_date, to = end_date, src = "yahoo") ## [1] "SPY" #detach("package:tsibble ", unload = TRUE) # tsibble clashes with the base R index() function SPY$ret_Rb <- Delt(SPY$SPY.Adjusted
对于 R 用户,feasts 包提供了 tsfeatures 与 tsibble 和 tidyverse 的集成,并扩展了额外功能。
tibble) %>% ~exp( newdata = .y)) )) %>% tidyr::unnest%>% as_tsibble ##绘制数据 ggplot() + geom_line