R extension breaks connection to extensions directory in NetLogo

£可爱£侵袭症+ 提交于 2019-12-22 02:05:32

问题


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?


回答1:


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)"


来源:https://stackoverflow.com/questions/34768723/r-extension-breaks-connection-to-extensions-directory-in-netlogo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!