R/to_from_data.table.R

Defines functions ts_dt ts_data.table ts_dts.data.table ts_data.table_dts

Documented in ts_data.table ts_dt

register_class("data.table")

# to ---------------------------------------------------------------------------

#' Convert to Class
#' @noRd
ts_data.table_dts <- function(x) {
  dts_rm(x)[]
}


# from -------------------------------------------------------------------------

#' @export
#' @method ts_dts data.table
ts_dts.data.table <- function(x) {
  dts_init(x)
}


# main converter ---------------------------------------------------------------

#' @name ts_ts
#' @export
ts_data.table <- function(x) {
  check_ts_boxable(x)
  if (relevant_class(x) == "data.table") {
    return(x)
  }
  ts_data.table_dts(ts_dts(x))
}

#' @name ts_ts
#' @export
ts_dt <- function(x) {
  ts_data.table(x)
}

Try the tsbox package in your browser

Any scripts or data that you put into this service are public.

tsbox documentation built on Oct. 23, 2024, 1:07 a.m.