I try to read a variable from a gdx file, write this variable to another gdx file and read it in again using the R bindings.
Code: Select all
> var <- rgdx("fulldata.gdx", list(name="v35_shEsPeT"))
> str(var)
List of 11
$ name : chr "v35_shEsPeT"
$ type : chr "variable"
$ dim : int 3
$ val : num [1:256, 1:4] 22 22 22 22 22 22 22 22 22 22 ...
$ form : chr "sparse"
$ uels :List of 3
..$ : chr [1:40] "1900" "1905" "1910" "1915" ...
..$ : chr [1:11] "AFR" "CHN" "EUR" "IND" ...
..$ : chr [1:114] "ngcc" "ngccc" "ngt" "gastr" ...
$ domains : chr [1:3] "ttot" "all_regi" "all_te"
$ domInfo : chr "full"
$ field : chr "l"
$ varTypeText: chr "positive"
$ typeCode : int 3
> wgdx("test.gdx", var)
Error in wgdx("test.gdx", var) :
Inconsistent dimension found: 'dim'=3 doesn't match implied 'uels' dimension=2.
Code: Select all
> var <- rgdx("fulldata.gdx", list(name="v35_shEsPeT", field="all"))
> str(var)
List of 11
$ name : chr "v35_shEsPeT"
$ type : chr "variable"
$ dim : int 3
$ val : num [1:3135, 1:5] 22 22 22 22 22 22 22 22 22 22 ...
$ form : chr "sparse"
$ uels :List of 4
..$ : chr [1:40] "1900" "1905" "1910" "1915" ...
..$ : chr [1:11] "AFR" "CHN" "EUR" "IND" ...
..$ : chr [1:114] "ngcc" "ngccc" "ngt" "gastr" ...
..$ : chr [1:5] "l" "m" "lo" "up" ...
$ domains : chr [1:4] "ttot" "all_regi" "all_te" "_field"
$ domInfo : chr "full"
$ field : chr "all"
$ varTypeText: chr "positive"
$ typeCode : int 3
> wgdx("test.gdx", var)
> str(rgdx("test.gdx"))
List of 6
$ name: chr "*"
$ type: chr "set"
$ dim : int 1
$ val : NULL
$ form: NULL
$ uels: chr [1:165] "1900" "1905" "1910" "1915" ...
Code: Select all
> str(rgdx("test.gdx", list(name="v35_shEsPeT", field="all")))
List of 11
$ name : chr "v35_shEsPeT"
$ type : chr "variable"
$ dim : int 3
$ val : num [1:3135, 1:5] 22 22 22 22 22 22 22 22 22 22 ...
$ form : chr "sparse"
$ uels :List of 4
..$ : chr [1:165] "1900" "1905" "1910" "1915" ...
..$ : chr [1:165] "1900" "1905" "1910" "1915" ...
..$ : chr [1:165] "1900" "1905" "1910" "1915" ...
..$ : chr [1:5] "l" "m" "lo" "up" ...
$ domains : chr [1:4] "ttot" "all_regi" "all_te" "_field"
$ domInfo : chr "relaxed"
$ field : chr "all"
$ varTypeText: chr "positive"
$ typeCode : int 3
I'm using gams 25.1 on Ubuntu 18.04.1 LTS (gdxrrw_1.0.2)
Thanks for your help!