R扩展名断开与NetLogo中扩展名目录的连接 [英] R extension breaks connection to extensions directory in NetLogo

查看:135
本文介绍了R扩展名断开与NetLogo中扩展名目录的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让R和NetLogo使用r扩展名相互交谈.我传递的是图形对象,而不是简单的变量.这意味着我需要从NetLogo导出文件并在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.

这似乎与在R中设置工作目录有关,因为以下MWE也会造成问题.

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

成功运行此命令,然后尝试对NetLogo进行任何编辑后,出现错误Can't find extension ....

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

只要我在运行R代码后不尝试编辑,NetLogo就会继续工作,并且我可以使用扩展名而不会出现问题.仅当我编辑代码并运行语法分析器(绿色对勾)时,问题才会出现.

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

我已经完成了一个错误报告,但是它显然是不可复制的.我正在运行Windows 8.1 64位.这对其他人来说有问题吗?

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?

推荐答案

在NetLogo中使用r扩展名时,我发现了类似的东西.

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

这篇关于R扩展名断开与NetLogo中扩展名目录的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆