rgdx {gdxrrw}R Documentation

Read data from GDX into R

Description

Read one data item (also called a symbol) from GDX into R, returning it as a list. Note that GDX files contain multiple symbols (e.g. sets, parameters). Each symbol is read with a separate call.

Usage

  rgdx(gdxName, requestList = NULL)  # generic form
  rgdx.param(gdxName, symName, names=NULL, crosstab=NULL) # return a parameter in a data frame
  rgdx.set(gdxName, symName, names=NULL)    # return a set in a data frame
  rgdx.scalar(gdxName, symName)             # return a scalar

Arguments

gdxName the name of the GDX file to read
requestList the name of the symbol to read, and (optionally) information about how much information to return and in what format. This argument must be a list. If omitted, the universe of UELs contained in the GDX file is returned
symName the name of the GDX symbol to read
names the column names to use in the data frame returned
crosstab a column name or index position to move from a row index to a column index, so that its values become column headings

Value

By default, the return value is a list with components describing the data item or symbol returned.

name symbol name
type symbol's data type: set, parameter, variable or equation
dim symbol dimension
val array containing the symbol data
form form of the data in val, i.e. full or sparse
uels vector of UEL lists, one list per symbol dimension
The functions rgdx.param and rgdx.set are special-purpose wrappers that read parameters and sets, respectively, and return them as data frames.

The function rgdx.scalar returns a scalar (i.e. a 0-dimensional parameter) as a double.

The output format can be adjusted via a global option. Documentation for this is in progress.

Note

A common problem is failure to load the external GDX libraries that are required to interface with GDX data. Use igdx to troubleshoot and solve this problem.

Author(s)

Original coding by Rishabh Jain. Adopted and packaged by Steve Dirkse. Maintainer: R@gams.com

See Also

igdx, wgdx, gdxInfo

Examples

  # run R-script trnsport.r from the data subdirectory of the gdxrrw package
  # to load up some data for writing to a GDX file
  data(trnsport)

  wgdx('rgdx1',sf,si,sj,sa,sb,sd)
  ou = rgdx('rgdx1')
  req <- list(name='f')
  of = rgdx('rgdx1',req)
  req <- list(name='i')
  oi = rgdx('rgdx1',req)
  req <- list(name='j')
  oj = rgdx('rgdx1',req)
  req <- list(name='a')
  oa = rgdx('rgdx1',req)
  req <- list(name='b')
  ob = rgdx('rgdx1',req)
  req <- list(name='d')
  od = rgdx('rgdx1',req)

  ## Not run: 
    # complete tests and examples can be run in the
    # extdata directory of the gdxrrw package
    # check .libPaths for a hint on where packages are installed
    setwd("C:/R/2.12/gdxrrw/extdata")
    source("tAll.R")
  
## End(Not run)

[Package gdxrrw version 0.0-1 Index]