Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R extension breaks connection to extensions directory in NetLogo

Tags:

r

netlogo

I am trying to get R and NetLogo to talk to each other using the r extension. I am passing graph objects rather than simply variables. This means I need to export a file from NetLogo and import a file in R, which means they need to point to the same directory. The code runs perfectly. However, once it is run, NetLogo loses the connection to the extensions folder.

It appears to be related to setting the working directory in R because the following MWE also creates the problem.

extensions [r]

to testSETWD
  r:eval "setwd(\"C:\")"
end

After running this successfully, then trying to do any edits to the NetLogo, I get the error Can't find extension ....

As long as I don't try to edit after running the R code, NetLogo continues to work and I can use the extensions without problems. The problem only arises when I edit the code and run the syntax parser (green tick).

I have done a bug report, but it is apparently not reproducible. I am running Windows 8.1 64bit. Is this a problem for anyone else?

like image 887
JenB Avatar asked Jan 13 '16 14:01

JenB


1 Answers

I found something similar when using the r extension in NetLogo.

I simply reset to the original working directory. For example:

;retain old working directory
r:eval "oldWD <- getwd()"

;The code you are running. ie.
r:eval "setwd(\"C:\")"
r:put "something" NetLogoSomething
r:eval "ReturnedThing <- SomethingElse(something)"

;And then reset the working directory: 
r:eval "setwd(oldWD)"
like image 191
Jordan Chetcuti Avatar answered Nov 15 '22 12:11

Jordan Chetcuti