read_gdx: Read gdx files

View source: R/read_gdx.R

read_gdxR Documentation

Read gdx files

Description

Read gdx files in a tidy way

Usage

read_gdx(
  files,
  symbol = NULL,
  col_names = NULL,
  attributes = "l",
  data_type = "tb",
  factors_as_strings = TRUE,
  names = NULL,
  names_to = "name"
)

Arguments

files

path to one or several gdx files

symbol

symbol name to read in the gdx. If NULL (default) returns a data.frame of the list of symbols in the gdx.

col_names

a vector of optional names for the columns.

attributes

character vector: the attributes to keep for variables, equations and sets. Possible values are '"l"' (the default) specifies the level, '"m"' specificies the marginal, '"lo"' specificies the lower bound, '"up"' specifies the upper bound, '"s"' specificies the scale, and '"te"' specified the text for sets.

data_type

character string: the type of data to output. Possible values are '"tb"' (the default) for a tibble, '"dt"' for a data.table, and '"df"' for a data.frame.

factors_as_strings

logical (default is TRUE) specifying whether factors should be transformed in strings.

names

a vector of optional names in case several gdx files are imported. The default is to use the gdx file name.

names_to

character string (default: '"name") specifying the new column to create to store the file names.

Value

A 'tibble()', a 'data.table', or a 'data.frame'.

Examples

fpath <- system.file("extdata", "trnsport.gdx", package = "gamsr")
read_gdx(fpath, "a")
read_gdx(fpath)
read_gdx(fpath, "x")
read_gdx(fpath, "f")
read_gdx(fpath, "i", attributes = "te")

christophe-gouel/gamsr documentation built on Feb. 13, 2025, 12:42 p.m.