Syncrosim › Forums › ST-Sim & State-and-Transition Simulation Models › Example of calling external R script from ST-Sim › Reply To: Example of calling external R script from ST-Sim
I have posted an example of how to do this here: http://www.apexrms.com/download/6717/
This example works with a minimum of SyncroSim 2.0.42, ST-Sim 3.1.42, and rsyncrosim 1.0.6. It should be forward compatible to future versions.
Note that to run this on the scenario properties under “Advanced | External Program” you need to point to the correct locations for the “externalProgramScript.R” file that is included in the zip as well as the correct location for your Rscript.exe, usually found in “…/Program Files/R/R-VERSION/bin/”.
There are two scenarios in the library, the first does not use the external program and the second does. In this example, the external program makes timber harvest conditional on the amount of a state attribute (ungulate winter habitat). The first scenario targets 10,000 acres of harvest per year. The second scenario makes this target conditional on habitat being above 12,000 acres, otherwise it sets the harvest target to 0.