read_ts: Import time series data from a file.

View source: R/read_ts.R

read_tsR Documentation

Import time series data from a file.

Description

If importing from a zip file, the archive should contain a single file with the extension .csv, .xlsx or .json.

Usage

read_ts(
  file,
  format = c("csv", "xlsx", "json", "zip"),
  sep = ",",
  skip = 0,
  column_names = c("date", "value", "series"),
  keep_last_freq_only = FALSE,
  force_xts = FALSE
)

Arguments

file

Path to the file to be read

format

Which file format is the data stored in? If no format is supplied, read_ts will attempt to guess from the file extension.

sep

character seperator for csv files. defaults to ','.

skip

numeric See data.table's fread.

column_names

character vector denoting column names, defaults to c("date","value","series).

keep_last_freq_only

in case there is a frequency change in a time series, should only the part of the series be returned that has the same frequency as the last observation. This is useful when data start out crappy and then stabilize after a while. Defaults to FALSE. Hence only the last part of the series is returned.

force_xts

If set to true, the time series will be returned as xts objects regargless of regularity. Setting this to TRUE means keep_last_freq_only is ignored.

Value

A named list of ts objects


tstools documentation built on June 7, 2023, 5:13 p.m.