![]() Main=\"Relationship between area and extinction probability\")" Rserve:eval "ext_prob<-100 * exp(- lambda * area)" I haven’t found a way of getting the working path from within Netlogo. The second block does it using a script that is placed in the directory that has to be set “by hand” first. The first function runs R using rserve:eval. So using a script seems to be the way to go. Note that one of the frustrations when typing R commands directly into rserve:eval is that quotation marks need escaping with a backslash. Watch for the line where the working directory is set and change it if you want to try it. The code and subsidiary files are all available from my GitHub repository by clicking here. Then it all seems to work fine.Īs an example I have added a little R script to the meta-population model to display the function that determines the extinction probabilities The default working directory for the R server is /tmp so it needs to be set to the directory with the script (and netlogo model) “by hand” by writing it into a getwd() command sent to R. However my solution was to write the commands as scripts and source them in. I found the rserver extension slightly frustrating at first, as you apparently can’t submit multiple lines at once and any command that returns a value (including for some reason commands to form functions) cause an error which halts Neltogo. In contrast, the rserver extension worked fine after installing the rserver packageĪnd then starting it from the terminal (not inside R) with I found that the r extension was rather tricky to setup with Java in Linux. This looks to provide some very useful addional functionality that can make up for the limitations of Netlogo. This allows you to use R commands and graphics while running or setting up models. This can be done using either the r extension or the rserve extensions for netlogo. The alternative is to run R within Netlogo. However I found that data transfer rates to be very slow. This would be useful for setting up simulation experiments. The RNetlogo package allows you to run netlogo from within R. There are several different ways to link Netlogo with R.
0 Comments
Leave a Reply. |