wgdx.reshape: Reshape R data to prepare it for writing to GDX

wgdx.reshapeR Documentation

Reshape R data to prepare it for writing to GDX

Description

Reshape the input data frame (assumed to be in "wide" form) into a "long" form suitable for passing to wgdx.lst or wgdx.df.

Usage

  wgdx.reshape(inDF, symDim, symName=NULL, tName="time",
               gdxName=NULL, setsToo=TRUE, order=NULL,
               setNames=NULL)

Arguments

inDF

data frame in "wide" form

symDim

dimension of the output GDX symbol

symName

name of the output GDX symbol

tName

index set name for the new index position created by reshaping

gdxName

name of the GDX file to write

setsToo

if TRUE, extract the index sets defined by inDF

order

specify the selection and ordering of the index columns when reshaping

setNames

specify explanatory text for the extracted index sets

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.

There is also the issue of our dependence on the reshape package. This still needs to be tightened up.

This routine is experimental/prototype work and perhaps temporary. Don't use it for production work.

Author(s)

Original coding by Steve Dirkse. Maintainer: R@gams.com

See Also

wgdx, igdx, rgdx, gdxInfo

Examples

  # take a sample dataset and reshape it
  str(airquality);
  oList <- wgdx.reshape (airquality, 3, symName="airquality",
                         tName = "dataType", order=c(5,6,0))
  ## Not run: 
    # send the data to GDX
    wgdx.lst("airquality", oList)
  
## End(Not run)

  ## 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(paste(.libPaths()[1],"/gdxrrw/extdata",sep=""))
    source("tAll.R")
  
## End(Not run)

GAMS-dev/gdxrrw-miro documentation built on July 11, 2024, 4:39 p.m.