
Last chance! 50% off unlimited learning
Sale ends in
ts_
turns an existing function into a function that can deal with
ts-boxable time series objects.
load_suggested(pkg)ts_(fun, class = "ts", vectorize = FALSE, reclass = TRUE)
ts_apply(x, fun, ...)
A function that accepts ts-boxable time series as an input.
external package, to be suggested (automatically added by ts_
)
predict()
. (See examples)
function, to be made available to all time series classes
class that the function uses as its first argument
should the function be vectorized? (not yet implemented)
logical, should the new function return the same same ts-boxable output as imputed?
ts-boxable time series, an object of class ts
, xts
, zoo
,
zooreg
, data.frame
, data.table
, tbl
, tbl_ts
, tbl_time
, tis
,
irts
or timeSeries
.
arguments passed to subfunction
The ts_
function is a constructor function for tsbox time series functions.
It can be used to wrap any function that works with time series. The default
is set to R base "ts"
class. ts_
deals with the conversion stuff,
'vectorizes' the function so that it can be used with multiple time series.
ts_examples, for a few useful examples of functions generated by
ts_
.
Vignette on how to make arbitrary functions ts-boxable.
# \donttest{
ts_(rowSums)(ts_c(mdeaths, fdeaths))
ts_plot(mean = ts_(rowMeans)(ts_c(mdeaths, fdeaths)), mdeaths, fdeaths)
ts_(function(x) predict(prcomp(x)))(ts_c(mdeaths, fdeaths))
ts_(function(x) predict(prcomp(x, scale = TRUE)))(ts_c(mdeaths, fdeaths))
ts_(dygraphs::dygraph, class = "xts")
# attach series to serach path
ts_attach <- ts_(attach, class = "tslist", reclass = FALSE)
ts_attach(EuStockMarkets)
ts_plot(DAX, SMI)
detach()
# }
Run the code above in your browser using DataLab