Skip to contents

Loads a delimited file from the directory specified by fundsr.data_dir, converts the date column to a proper Date, and coerces all other columns to numeric.

Usage

read_timeseries(file, time_unit = c("ms", "s", "us", "ns"))

Arguments

file

Filename to read (relative to getOption("fundsr.data_dir")).

time_unit

Character scalar giving the unit of the numeric date column (Unix epoch). One of "ms" (default), "s", "us", "ns".

Value

A tibble with parsed date and numeric value columns.

Details

The reader is chosen by file extension: .csv uses readr::read_csv() and .tsv/.tab/.txt uses readr::read_tsv(). Gzipped variants such as .csv.gz and .tsv.gz are also supported.

The function assumes a column named date exists and represents a Unix timestamp. All non-date columns are coerced with as.numeric() (non-parsable values become NA).