VENSIM output data from R

Use this forum to post Vensim related questions.
Post Reply
morebru
Junior Member
Posts: 4
Joined: Mon Jun 07, 2021 10:02 am
Vensim version: DSS

VENSIM output data from R

Post by morebru »

Hello,

Is there a way of obtaining output data from a vdf file like the function vensim_get_data() function, but insted of using Excel, using R? Besides, is there a way of converting a .tab file to a .vdf file using R?

Thanks.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: VENSIM output data from R

Post by Administrator »

Can you explain what you need to do?

You can export a VDF to CSV, TAB etc. You can also convert CSV, TAB etc to VDF. I'm sure R can read CSV and TAB files.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
morebru
Junior Member
Posts: 4
Joined: Mon Jun 07, 2021 10:02 am
Vensim version: DSS

Re: VENSIM output data from R

Post by morebru »

I would like to launch Vensim authomatically from R for testing many parameters in my model. For this, I need to create a .cmd file which will read a .vdf. From R I can create a .tab file without problem, but it must be read by Vensim, so that the .tab file must be converted to .vdf format. Is there a way of doing this from R? Another task I need to do would be to read the model outputs that are in .vdf format into R. From Excel is it possible to do it using the vensim_get_data() function. I was wonderig if it is possible to build a similar function in R to extract outputs from a .vdf file.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: VENSIM output data from R

Post by Administrator »

Vensim can read TAB files as well.
http://www.vensim.com/documentation/fn_ ... _data.html

Or you can convert the TAB file before using it,
http://www.vensim.com/documentation/tab2vdf.html

And if you are launching Vensim via a command file, you can export the results once the simulation is finished. I'm guessing as you haven't uploaded anything for us to see, I'm assuming you have something like the following in your command file.
SPECIAL>LOADMODEL|mymodel.mdl
MENU>RUN!o

You can add the following after the MENU>RUN command
MENU>VDF2TAB|vdffile|tabfile

and read that back into R.

So the following would load a model, import a tab file, run it and export the VDF to a TAB.

MENU>TAB2VDF|mytabfile.tab|myvdffile.vdfx
SPECIAL>LOADMODEL|mymodel.mdl
MENU>RUN!o
MENU>VDF2TAB|myrun.vdfx|myrun.tab


Relevant links,
http://www.vensim.com/documentation/vdf2tab.html
http://www.vensim.com/documentation/tab2vdf.html
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
morebru
Junior Member
Posts: 4
Joined: Mon Jun 07, 2021 10:02 am
Vensim version: DSS

Re: VENSIM output data from R

Post by morebru »

That is exactly what I nedded. Thanks a lot.
SionC
Member
Posts: 39
Joined: Tue Nov 18, 2008 8:44 am

Re: VENSIM output data from R

Post by SionC »

Hi morebru - are you running the command files from R? I have been trying to run simulations using R via the Vensim dll but I am not having much success!
morebru
Junior Member
Posts: 4
Joined: Mon Jun 07, 2021 10:02 am
Vensim version: DSS

Re: VENSIM output data from R

Post by morebru »

Hi SionC, neither am I. I am trying to automatize some runs but without much success so far.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: VENSIM output data from R

Post by Administrator »

If either of you can share some code, I can try. I've never used R before, but should be able to figure out how to do things.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
SionC
Member
Posts: 39
Joined: Tue Nov 18, 2008 8:44 am

Re: VENSIM output data from R

Post by SionC »

Hi - Great. I'll can set up a GIT repository next week and we can share things that way if that sounds like a good way ahead.
Post Reply