Package: tsbox 0.4.2

Christoph Sax

tsbox: Class-Agnostic Time Series

Time series toolkit with identical behavior for all time series classes: 'ts','xts', 'data.frame', 'data.table', 'tibble', 'zoo', 'timeSeries', 'tsibble', 'tis' or 'irts'. Also converts reliably between these classes.

Authors:Christoph Sax [aut, cre], Cathy Chamberlin [rev], Nunes Matt [rev]

tsbox_0.4.2.tar.gz
tsbox_0.4.2.zip(r-4.5)tsbox_0.4.2.zip(r-4.4)tsbox_0.4.2.zip(r-4.3)
tsbox_0.4.2.tgz(r-4.5-any)tsbox_0.4.2.tgz(r-4.4-any)tsbox_0.4.2.tgz(r-4.3-any)
tsbox_0.4.2.tar.gz(r-4.5-noble)tsbox_0.4.2.tar.gz(r-4.4-noble)
tsbox_0.4.2.tgz(r-4.4-emscripten)tsbox_0.4.2.tgz(r-4.3-emscripten)
tsbox.pdf |tsbox.html
tsbox/json (API)
NEWS

# Install 'tsbox' in R:
install.packages('tsbox', repos = c('https://packages.ropensci.org', 'https://cloud.r-project.org'))

Reviews:rOpenSci Software Review #464

Bug tracker:https://github.com/ropensci/tsbox/issues

Pkgdown site:https://docs.ropensci.org

On CRAN:tsbox-0.4.2(2024-10-22)

Conda:

graphicstime-series

10.61 score 150 stars 4 packages 496 scripts 3.1k downloads 64 exports 4 dependencies

Last updated 5 months agofrom:0a80208f0f (on main). Checks:9 OK. Indexed: yes.

TargetResultLatest binary
Doc / VignettesOKMar 14 2025
R-4.5-winOKMar 14 2025
R-4.5-macOKMar 14 2025
R-4.5-linuxOKMar 14 2025
R-4.4-winOKMar 14 2025
R-4.4-macOKMar 14 2025
R-4.4-linuxOKMar 14 2025
R-4.3-winOKMar 14 2025
R-4.3-macOKMar 14 2025

Exports:%ts-%%ts*%%ts/%%ts+%check_ts_boxablecolors_tsboxcopy_classload_suggestedrelevant_classscale_color_tsboxscale_fill_tsboxtheme_tsboxts_ts_applyts_bindts_boxablets_cts_chaints_compoundts_data.framets_data.tablets_defaultts_dfts_diffts_diffyts_dtts_dtsts_dygraphsts_endts_first_of_periodts_forecastts_frequencyts_ggplotts_indexts_irtsts_lagts_longts_na_interpolationts_na_omitts_pcts_pcats_pcyts_pickts_plotts_prcompts_regularts_savets_scalets_seasts_spants_startts_summaryts_tblts_tibbletimets_timeSeriests_tists_trendts_tsts_tsibblets_tslistts_widets_xtsts_zoots_zooreg

Dependencies:anytimeBHdata.tableRcpp

Introduction to tsbox

Rendered fromtsbox.Rmdusingknitr::rmarkdownon Mar 14 2025.

Last update: 2023-03-07
Started: 2018-02-18

Time conversion and regularization

Rendered fromconvert.Rmdusingknitr::rmarkdownon Mar 14 2025.

Last update: 2021-07-26
Started: 2018-02-25

User defined ts-functions

Rendered fromts-functions.Rmdusingknitr::rmarkdownon Mar 14 2025.

Last update: 2021-07-26
Started: 2018-02-25

Citation

To cite tsbox in publications use:

Sax C (2021). tsbox: Class-Agnostic Time Series in in R. R package, https://docs.ropensci.org/tsbox/.

Corresponding BibTeX entry:

  @Manual{,
    title = {tsbox: Class-Agnostic Time Series in in {R}},
    author = {Christoph Sax},
    note = {{R package}},
    url = {https://docs.ropensci.org/tsbox/},
    year = {2021},
  }

Readme and manuals

tsbox: Class-Agnostic Time Series in R

The R ecosystem knows a vast number of time series standards. Instead of creating the ultimate 15th time series class, tsbox provides a set of tools that are agnostic towards the existing standards. The tools also allow you to handle time series as plain data frames, thus making it easy to deal with time series in a dplyr or data.table workflow.

See tsbox.help for the full documentation of the package.

To install the stable version from CRAN:

install.packages("tsbox")

To install the development version:

# install.packages("remotes")
# remotes::install_github("ropensci/tsbox")
install.packages("tsbox", repos = c('https://ropensci.r-universe.dev', 'https://cloud.r-project.org'))
install.packages("ropensci/tsbox", repos = "https://ropensci.r-universe.dev")
Convert everything to everything

tsbox is built around a set of converters, which convert time series stored as ts, xts, data.frame, data.table, tibble, zoo, zooreg, tsibble, tibbletime, timeSeries, irts or tis to each other:

library(tsbox)
x.ts <- ts_c(fdeaths, mdeaths)
x.xts <- ts_xts(x.ts)
x.df <- ts_df(x.xts)
x.dt <- ts_dt(x.df)
x.tbl <- ts_tbl(x.dt)
x.zoo <- ts_zoo(x.tbl)
x.zooreg <- ts_zoo(x.zoo)
x.tsibble <- ts_tsibble(x.zooreg)
x.tibbletime <- ts_tibbletime(x.tsibble)
x.timeSeries <- ts_timeSeries(x.tibbletime)
x.irts <- ts_irts(x.tibbletime)
x.tis <- ts_tis(x.irts)
all.equal(ts_ts(x.tis), x.ts)
#> [1] TRUE
Use same functions for time series classes

Because this works reliably, it is easy to write functions that work for all classes. So whether we want to smooth, scale, differentiate, chain, forecast, regularize or seasonally adjust a time series, we can use the same commands to whatever time series class at hand:

ts_trend(x.ts)
ts_pc(x.xts)
ts_pcy(x.df)
ts_lag(x.dt)
Time series of the world, unite!

A set of helper functions makes it easy to combine or align multiple time series of all classes:

# collect time series as multiple time series
ts_c(ts_dt(EuStockMarkets), AirPassengers)
ts_c(EuStockMarkets, mdeaths)

# combine time series to a new, single time series
ts_bind(ts_dt(mdeaths), AirPassengers)
ts_bind(ts_xts(AirPassengers), ts_tbl(mdeaths))
And plot just about everything

Plotting all kinds of classes and frequencies is as simple as it should be. And we finally get a legend!

ts_plot(ts_scale(ts_c(mdeaths, austres, AirPassengers, DAX = EuStockMarkets[ ,'DAX'])))

Cheatsheet

Help Manual

Help pageTopics
tsbox: Class-Agnostic Time Seriestsbox-package tsbox
Re-Class ts-Boxable Objectcopy_class
Extract Relevant Classrelevant_class
Constructing ts-Functionsload_suggested ts_ ts_apply
Arithmetic Operators for ts-boxable objects%ts*% %ts+% %ts-% %ts/% ts_arithmetic
Bind Time Seriests_bind ts_chain
Test if an Object is ts-Boxablecheck_ts_boxable ts_boxable
Collect Time Seriests_c
Default Column Namests_default
Internal Time Series Classts_dts
Principal Components, Dygraphs, Forecasts, Seasonal Adjustmentts_dygraphs ts_examples ts_forecast ts_na_interpolation ts_prcomp ts_seas
Use First Date of a Periodts_first_of_period
Change Frequencyts_frequency
Plot Time Series, Using ggplot2colors_tsbox scale_color_tsbox scale_fill_tsbox theme_tsbox ts_ggplot
Indices from Levels or Percentage Ratests_compound ts_index
Lag or Lead of Time Seriests_lag
Reshaping Multiple Time Seriests_long ts_wide
Omit NA valuests_na_omit
First Differences and Percentage Change Ratests_diff ts_diffy ts_pc ts_pca ts_pcy
Pick Series (Experimental)ts_pick
Plot Time Seriests_plot
Enforce Regularityts_regular
Save Previous Plotts_save
Scale and Center Time Seriests_scale
Limit Time Spants_span
Time Series Propertiests_summary
Loess Trend Estimationts_trend
Convert Everything to Everythingts_data.frame ts_data.table ts_df ts_dt ts_irts ts_tbl ts_tibbletime ts_timeSeries ts_tis ts_ts ts_tsibble ts_tslist ts_xts ts_zoo ts_zooreg
Start and end of time seriestsbox-defunct ts_end ts_start