当我尝试使用NLStart()函数从R启动RNetLogo时。我收到有关java的消息,GUI无法打开。我使用的是64位的MacOsX 10.9.5,NetLogo 5.1.0和R 3.1.1。
> library(rJava)
> library(RNetLogo)
> nl.path <- "/Applications/NetLogo\ 5.1.0/NetLogo\ 5.1.0.app"
> NLStart(nl.path, nl.version=5, gui=FALSE)
java.lang.NoClassDefFoundError: org/nlogo/workspace/Controllable
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:249)
Caused by: java.lang.ClassNotFoundException
at RJavaClassLoader.findClass(RJavaClassLoader.java:383)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 2 more
之后我尝试使用“JGR and Deducer and deducer extras”。 代码和错误是:
> install.packages(c("JGR","Deducer","DeducerExtras”))
> Sys.setenv(NOAWT=1)
> library(JGR)
> Sys.unsetenv("NOAWT")
> JGR()
启动JGR时,代码为:
Loading required package: JGR
Loading required package: rJava
Loading required package: JavaGD
Loading required package: iplots
starting httpd help server ... done
Loading required package: RNetLogo
Loading required package: DeducerExtras
Loading required package: Deducer
Loading required package: ggplot2
Use suppressPackageStartupMessages to eliminate package startup messages.
Loading required package: car
Loading required package: MASS
Attaching package: ‘Deducer’
Loading required package: irr
Loading required package: lpSolve
> nl.path<-"/users/Pabolo/Applications/NetLogo\ 5.1.0/NetLogo.jar"
> NLStart(nl.path)
Error on setwd(nl.path) : you can not change the working directory.
使用nl.path作为app dir的路径。 有一些错误。 我在JGR()上运行所有这些。
> nl.path<-"/Applications/NetLogo\ 5.1.0"
> NLStart(nl.path)
Warning: ch.randelshofer.quaqua.util.OSXPreferences failed to load /Users/Pabolo/Library/Preferences/.GlobalPreferences.plist
java.io.IOException: parseReal: unsupported byte count:128
at ch.randelshofer.quaqua.util.BinaryPListParser.parseReal(BinaryPListParser.java:703)
at ch.randelshofer.quaqua.util.BinaryPListParser.parseObjectTable(BinaryPListParser.java:424)
at ch.randelshofer.quaqua.util.BinaryPListParser.parse(BinaryPListParser.java:315)
at ch.randelshofer.quaqua.osx.OSXPreferences.readPList(OSXPreferences.java:176)
at ch.randelshofer.quaqua.osx.OSXPreferences.updateCache(OSXPreferences.java:99)
at ch.randelshofer.quaqua.osx.OSXPreferences.ensureCached(OSXPreferences.java:90)
at ch.randelshofer.quaqua.osx.OSXPreferences.get(OSXPreferences.java:79)
at ch.randelshofer.quaqua.osx.OSXPreferences.getString(OSXPreferences.java:45)
at ch.randelshofer.quaqua.BasicQuaquaLookAndFeel.initSystemColorDefaults(BasicQuaquaLookAndFeel.java:151)
at ch.randelshofer.quaqua.leopard.Quaqua15LeopardLookAndFeel.initSystemColorDefaults(Quaqua15LeopardLookAndFeel.java:208)
at ch.randelshofer.quaqua.BasicQuaquaLookAndFeel.getDefaults(BasicQuaquaLookAndFeel.java:76)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:520)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:564)
at org.nlogo.swing.Utils.setSystemLookAndFeel(Utils.java:41)
at org.nlogo.app.App.<init>(App.scala:302)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.picocontainer.injectors.AbstractInjector.newInstance(AbstractInjector.java:147)
at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:332)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:272)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:354)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:692)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:646)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:671)
at org.nlogo.app.App$.main(App.scala:140)
at org.nlogo.app.App.main(App.scala)
at nlcon.NLink_v5.<init>(NLink_v5.java:96)
at org.rosuda.JRI.Rengine.rniRunMainLoop(Native Method)
at org.rosuda.JRI.Rengine.run(Rengine.java:640)
unable to find translation for: edit.viewSettings.2D.frameRate in GUI_Strings for locale: es
unable to find translation for: edit.viewSettings.2D.frameRate.info in GUI_Strings for locale: es
>
答案 0 :(得分:0)
您必须将路径更改为:nl.path <- "/Applications/NetLogo 5.3/app"
。
他们更改了目录结构,以便netlogo jar文件现在位于“app”子目录中。
来源:https://stackoverflow.com/a/34837036/468305
希望有所帮助,它对我有用。
答案 1 :(得分:0)
它说你不能改变你的工作目录。也许开始一个新的会话。您的反斜杠之一也走错了路。
要找到您的 NetLogo 路径,请尝试 def my_function(list_1: list = ['apple','orange','nuts','fruits','things']):
pass
,然后导航到 NetLogo Jar 文件。然后当您打开文件路径时,将显示在 R studios 控制台中。将文件路径复制到 NLStart 命令中,该命令应如下所示。
file.choose()
最后,确保您的 Java、NetLogo 和 R 都在 64 位(适用于我)或 32 位上运行,但尽量不要混合使用。最后尝试直接从 R GUI 而不是 RStudio 运行代码。这对我第一次用 R 打开 Netlogo 很有帮助。
我有一个 youtube 视频 (https://www.youtube.com/watch?v=zWMdaTEPTOc),解释了如何从 R 打开 NetLogo,我的所有功能代码(2021 年 8 月)都可以在 here 中找到。