Learn R Programming

TSsdmx (version 2016.8-1)

TSsdmxMethods: Methods to wrap sdmx for TSdbi Generics

Description

Get a time series (matrix) using SDMX, for example, from the OECD database.

Usage

sdmx(...) "TSconnect"( q, dbname, user="", password = "", host="", ...) "TSget"( serIDs, con, TSrepresentation = options()$TSrepresentation, tf = NULL, start = tfstart(tf), end = tfend(tf), names=serIDs, quiet = TRUE, ...) "TSdates"( serIDs, con, vintage=NULL, panel=NULL, ... ) "TSdescription"(x, con, ... ) "TSdoc"(x, con, ... ) "TSlabel"(x, con, ... ) "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).
names
optional character vector to use for series names in the R object. See details.
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.)
quiet
logical to suppress progress report.
user
(unused) a character string indicating a user id.
password
(unused) a character string indicating a password.
host
(unused) a character string indicating a host computer.
...
Arguments passed to other methods or to sdmxCall.

Value

Details

These functions interface to the SDMX databases such as the OECD web portal. TSget is a wrapper to RJSDMX::getSDMX to provided an interface that is consistent with TSdbi. The TSdbi function argument serIds is passed as the series to return, and dbname indicates the data provider (e.g. "OECD"). The SDMX query syntax allows for the possibility of indicating several series by using +, | and * characters. For example, 'G20_PRICES.CAN+MEX.CPALTT01.IXOB.M' would indicate Canada and Mexico, while 'G20_PRICES.*.CPALTT01.IXOB.M' would indicate all countries. By default, TSget will uses series names as returned by the SDMX call. The argument names can be used to replace names, but only in some situations. If * is used in serIds then names will be ignored because the number and order of the returned series cannot be guaranteed. If + or | are used in more than one field then names will be ignored. If + or | are used in only one field then names will applied, but this requires that TSget sort the series in the specified order since the SDMX call does not guarantee the return order. (This may change, an enhancement request has been made.) Thus, specifying serIds as 'G20_PRICES.CAN+MEX.CPALTT01.IXOB.M' or specifying it as c('G20_PRICES.CAN.CPALTT01.IXOB.M', 'G20_PRICES.MEX.CPALTT01.IXOB.M') should return the same result, but the mechanism is different. In the first case the getSdmx call returns both series and then the TSget sorts the result into the proper order to apply the names. In the second case the TSget code makes two separate calls to getSdmx.

The treatment of start and end dates also differs in a subtle way depending on the specification. A character specification is assumed to be an SDMX specification, so start="1990-Q1" is passed unchanged as part of the getSdmx call whereas start=c(1990,1) cannot detemine the frequency, so uses getSdmx to return the whole series, then truncates at the appropriate start date.

(See TSget in TSdbi for more details on TSget.)

TSsdmx does not support writing data to the source.

The class TSsdmxConnection extends class DBIConnection in the DBI package.

See the vignette in TSdata for additional examples.

When the TSsdmx method TSconnect is first used the underlying code reads a configuration file that sets, among other things, the amount of printout done during retrieval. The default is useful for debugging but will be more than typically expected in an R session. A system wide default location for this file can be set. A user's default will be found in the users home directory (~/.SdmxClient in Linux). More details on this file can be found at https://github.com/amattioc/SDMX/wiki/Configuration. R users will probably want to specify SDMX.level = OFF and java.util.logging.ConsoleHandler.level = OFF to suppress most printed output. Otherwise, R programs that use try() will not suppress printed error messages as they should. With the levels set OFF, the error and warning messages are still returned to the R to deal with as appropriate.

See Also

getSDMX, TSdates, TSget, tfwindow,

Examples

Run this code
  require("TSsdmx")
  require("tfplot")
  ## Not run: 
#   oecd <- TSconnect("sdmx", dbname="OECD")
#   x <- TSget('G20_PRICES.CAN.CPALTT01.IXOB.M',oecd) 
#   tfplot(x)
#   ## End(Not run)

Run the code above in your browser using DataLab