Write one or more time series to a .xls spreadsheet file
1 2 3
a time series or matrix of time series.)
additional time series objects (like x).
a string to use for the file name.
Logical indicating if NA should be removed from the beginning and end of a series.
an integer indicating the format to use for dates. (See details.)
string or vector of strings to use as header on date column.
logical passed to WriteXLS.
This functions uses
WriteXLS to write time series data to an .xls spreadsheet
file. If the object
x has mulitple series then they will be put on
the same sheet. Additional objects in ... will be put on additional pages.
The first line of each sheet will have column headers using
from the series in the column. The first column will have dates and the
heading for that column will be determined by
dateHeader. This can be a
vector of length equal the number of sheets, of a single character string, in
which case it is replicated for each sheet. The
dateHeader is a
might be useful for indication information like the date of the last
observation in a known place on the sheet (A1) for indicating on a graph.
For convenience, the year, period, and a character
representation of the period are indicated in columns 2 to 4. This is followed
by columns of the data.
NULL (the default) then the sheet names will
be generated from the first series name in each object. If
is supplied then it should have an element for
x and for each object
WriteXLS does not find a version of perl with appropriate modules
then a work around is attempted using
WriteCSV handles only a single object
x which can have mulitple
series. These are wtten as columns in the comma separated value file.
dateFormat can be 0 indicating no date, 1 indicating a format like
"Jan 1969", 2 indicating a format like 1969,1, or 3 indicating a
format like 1969,"Jan",. Only 0 or 1 are supported for data other than monthly
and quarterly frequencies.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
tofile <- tempfile() z <- ts(1:10, start=c(1999,2), freq=12) seriesNames(z) <- "ser 1" TSwriteXLS(z, FileName=tofile) zz <- tbind(z, diff(z)) seriesNames(zz) <- c("ser 1", "diff") TSwriteXLS(zz, FileName=tofile, SheetNames="2 series") zz <- ts(1:10, start=c(1999,1), freq=1) seriesNames(zz) <- "annual ser" TSwriteXLS(z, zz, FileName=tofile, SheetNames=c("monthly", "annual")) unlink(tofile)