Wrapper for wgdx available?

questions about GAMS' tools
Post Reply
User avatar
Renger
Posts: 639
Joined: 7 years ago

Wrapper for wgdx available?

Post by Renger »

Hi
I work a lot with R and Gams. Usually only from Gams to R, but nowadays more and more from R to Gams.
Writing the code for sending a parameter with 7 dimensions from R to gdx using wgdx is quite error prone (on my side), so I stopped using it altogether and do it with one line of code in R and then 3 lines in Gams.

The R-code for sending the dataframe "cardata_wide" to a csv file

Code: Select all

write_csv(path="cardata.csv",cardata_wide)
And here the code for importing it in Gams:

Code: Select all

$call csv2gdx .\R\cardata.csv id=cardata_wide Index=(1,6,10,12,13,16) Values=(2..5,7..9,11,14,15)  UseHeader=Y
$gdxin cardata.gdx
$load cost = cardata_wide, car = dim1, em=dim2, lstkw =dim5, fryr=dim3, lryr=dim4,trst=dim6, attr=dim7
Anybody having a shorter method using wgdx?
My point: It would be great if there would be a wgdx-wrapper in R that does the same kind of trick as the csv2gdx tool. I probably write one myself, but perhaps somebody encountered the same problem and done it already.

Cheers
Renger


Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply