TSdbiMethods: Methods for TSdbi Generics to Connect to Spreadsheets

Description Usage Arguments Details Value See Also Examples

Description

Get a time series (matrix) from a spreadsheet.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
    xls(...) 
    ## S4 method for signature 'xlsConnection,missing'
TSconnect(q, dbname, 
       map=list(ids, data, dates, names=NULL, description=NULL, sheet=1,
         tsrepresentation = function(data,dates){zoo(data, as.Date(dates))}),
	  ...)
    ## S4 method for signature 'character,TSxlsConnection'
TSget(
	serIDs, con, TSrepresentation = options()$TSrepresentation, 
	tf = NULL, start = tfstart(tf), end = tfend(tf), names=serIDs, ...)
    ## S4 method for signature 'character,TSxlsConnection'
TSdates(
	serIDs, con, vintage=NULL, panel=NULL, ... )  
    ## S4 method for signature 'character,TSxlsConnection'
TSdescription(x, con, ... )  
    ## S4 method for signature 'character,TSxlsConnection'
TSdoc(x, con, ... )  
    ## S4 method for signature 'character,TSxlsConnection'
TSlabel(x, con, ... )  
    ## S4 method for signature 'character,TSxlsConnection'
TSsource(x, con, ... )  

Arguments

q

A character string indicating the query interface to use, or a database connection object.

dbname

The name of the database to which the connection should be established, omitted if q is a database connection object.

con

a database connection object.

serIDs

identifiers for series on the database.

vintage

character string indicating vintage of the series on the database (not supported by this database).

panel

character string indicating panel of the series on the database (not supported by this database).

x

time series data(TSput), or identifiers for series on the database (TSdoc and TSdescription).

sheet

optional integer to indicate the sheet of the workbook to use default=1).

names

optional character vector to use for series names in the R object.

tf

time frame for trimming data, passed to tfwindow.

start

time frame for trimming data, passed to tfwindow.

end

time frame for trimming data, passed to tfwindow.

TSrepresentation

time representation for returned series. (See TSget in package TSdbi.)

map

A list with elements indicating the location of data, serIDs, dates, and optional metadata (see Details).

...

Arguments currently unused.

Details

These functions interface to the spreadsheets (.xls) files. TSget is just a wrapper to read.xls to provide an interface that is consistent with TSdbi. The TSdbi function argument serId is passed as the series to return, dbname indicates the spreadsheets file. (See TSget in TSdbi for more details on how this works.)

Note that the data is read into the object con when the connection is established, so this will not update if the source file changes (in contrast to other TS* packages).

Note also that dates may display in the spreadsheet one way (e.g. 02-Jan-1989), show in the spreadsheet formula box in another way (e.g. 1989-01-02), and import still differently (e.g. 02/Jan/1989). And the format could change when the file is saved, possibly depending on what features are available in the spreadsheet program. The imported format needs to be used when tsrepresentation is specified. If in doubt, look at con@dates

TSxls does not support writing data to the source.

The classes xlsDriver and TSxlsConnection extend classes DBIDriver and DBIConnection in the DBI package.

See the vignette in package TSdata for additional examples.

Value

Depends.

See Also

TSdates, TSget, tfwindow,

Examples

1
2
3
4
5
6
7
8
9
  require("tfplot")
  if (require("TSxls")){
    con <- try(TSconnect("xls", dbname="OECD"))
    if(! inherits(con, "try-error")) {
        x <- TSget("whatever", con)
        tfplot(x)
       }
    }
  

TSxls documentation built on Sept. 23, 2019, 3:01 a.m.

Related to TSdbiMethods in TSxls...