Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tsScan

Read and Write Time Series to Files


Description

Read and write time series to files.

Usage

tsScan(file="", skip=1, nseries=1, sep=",", 
       na.strings=c("NA", "NC", "ND"), ...)

   tsWrite(x, file="data", header=TRUE, sep=",", digits=16)

Arguments

file

name of file to read or write.

x

A time series or time series matrix.

skip

number of lines to skip at start of file before reading data.

nseries

number of columns of series to expect.

sep

field separator.

na.strings

charaters that should be treated as NA.

header

a logical indicating is a header line should be written.

digits

number of significant digits to print.

...

additional arguments passed to scan.

Details

Read and write a file with time series data. By default the file is comma separated values (csv) with one header line (the series names on write, ignored on read). The year and period are the first two columns, with series in following columns. These are wrappers for scan and write.

Beware that short digits settings will result in truncated data.

Value

A time series vector or matrix.

See Also

Examples

z <- ts(matrix(100 + rnorm(200),100,2), start=c(1991,1), frequency=4)
tsWrite(z, file="tmp.test.data.csv")
zz <- tsScan("tmp.test.data.csv", nseries=2)

max(abs(z - zz))

tfplot

Time Frame User Utilities

v2015.12-1
GPL-2
Authors
Paul Gilbert <pgilbert.ttv9z@ncf.ca>
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.