R 如何从列表中筛选所有季度时间序列?
我有一个列表,包含几个不同长度和频率的时间序列。类似于此:R 如何从列表中筛选所有季度时间序列?,r,list,time-series,R,List,Time Series,我有一个列表,包含几个不同长度和频率的时间序列。类似于此: library(tstools) list <- list(ts(runif(200), end = c(2021,1), frequency = 12), ts(runif(150), end = c(2021,1), frequency = 12), ts(runif(75), end = c(2021,1), frequency = 4),
library(tstools)
list <- list(ts(runif(200), end = c(2021,1), frequency = 12),
ts(runif(150), end = c(2021,1), frequency = 12),
ts(runif(75), end = c(2021,1), frequency = 4),
ts(runif(100), end = c(2021,1), frequency = 12),
ts(runif(25), end = c(2021,1), frequency = 4),
ts(runif(100), end = c(2021,1), frequency = 12)
)
库(tstools)
列出其中任何一项都将提取季度序列。没有使用任何软件包
Filter(function(x) frequency(x) == 4, list)
或
freq其中任何一个都将提取季度序列。没有使用任何软件包
Filter(function(x) frequency(x) == 4, list)
或
freq
s <- split(list, freq) # freq defined above
s[["4"]]
L <- lapply(s, do.call, what = cbind) # s is defined above
L[["4"]] # returns a multivariate series with all the quarterlies