tisFromCsv {tis} | R Documentation |
Reads tis
(Time Indexed Series) from a csv file,
returning the series in a list, and optionally storing them in an environment.
tisFromCsv(csvFile, dateCol = "date", dateFormat = "%Y%m%d", tif = NULL, defaultTif = "business", save = F, envir = parent.frame(), naNumber = NULL, tolerance = sqrt(.Machine$double.eps), ...)
csvFile |
A file name, connection, or URL acceptable to
read.csv . Also see the the rest of this help entry for
required attributes of this file. |
dateCol |
name of the column holding dates. This column must be present in the file. |
dateFormat |
format of the dates in dateCol . If
the dateCol cells contain Excel dates, use dateFormat ==
"excel" . If they are strings, see strptime for date formats. |
tif |
time index frequency of the data. If this is NULL
(the default), the function tries to infer the frequency from the
dates in the ymdCol column. |
defaultTif |
If the frequency can't be inferred from the dates in
the ymdCol column, this tif frequency will be used.
This should be a rare occurrence. |
save |
If true, save the individual series in the enviroment
given by the envir argument. Default is FALSE . |
envir |
if save == TRUE , the individual series (one per
column) are saved in this enviroment. Default is the frame of the caller. |
naNumber |
if non-NULL , numbers within tolerance of
this number are considered to be NA values. NA strings can
be specified by including an na.strings argument as one of
the ... arguments that are passed along to read.csv . |
tolerance |
Used to determine whether or not numbers in the file
are close enough to naNumber to be regarded as equal to it.
The default is about 1.48e-08. |
... |
Additional arguments passed along to the underlying
read.csv function. |
File Requirements: The csv file must have column names
across the top, and everything but the first row should be numeric.
There must be as many column names (enclosed in quotes) as there are
columns, and the column named by dateCol
must have dates in the
format indicated by dateFormat
. The dateCol
column must be present.
Missing (NA) values: Missing and NA values are the same thing.
The underlying read.csv
has "," as its default separator and
"NA" as its default na.string, so the rows
20051231,,13,,42,NA, 20060131,NA,14,,43,,NAindicate
NA
values for both the Dec 2005 and Jan 2006
observations of the first, third, fifth and sixth series.
The values in the file are read into a single large tis
series,
with a tif
(Time Index Frequency) inferred from the first six
dates in the ymd column. The first date is converted to a ti
(Time Index) of that frequency and becomes the start
of the
series. Each individual column is then windowed via naWindow
to strip off leading and trailing NA
values, and the resulting
series are put into a list with names given by lower-casing the column
names from the csv file. If save
is TRUE
, the series
are also stored in envir
using those same names.
A list of tis
time series, one per column of the csv file.
The list is returned invisibly if save
is TRUE
.
ti
, tis
, read.csv
,
read.table