RNetlogo linkage help

282 views
Skip to first unread message

Paul Christoph

unread,
Feb 19, 2021, 4:14:58 PM2/19/21
to netlogo-users
Greetings,

I am trying to play with the fire model through netlogo via R.  I guess the first thing is to confirm that Rnetlogo is all up to date with with Netlogo 6.1.1 and R 4.0.2 since most of the help I have looked for online is a two or so years old.

I think my main problem might be with the working directory but not exactly sure.

I begin the R sessions with adding
- library(rJava)
- install.packages("RNetLogo")
- library(RNetLogo)
Now I have tried various different working directories
setwd(): 
("C:/Users/name/Applications/NetLogo 6.1.1")
"C:/Users/name/Applications/NetLogo 6.1.1.app"
"/Users/pauldoehring/Library/Applications/Netlogo 6.1.1/app"
"C:/Users/pauldoehring/Library/Applications/Netlogo 6.1.1/app")
"/Users/name/Library/Application Support/NetLogo/6.1/r/"
The last one gets me somewhere after I set that wd to nl.path and command
NLStart(nl.path) and get this response
ava.lang.NoClassDefFoundError: org/nlogo/workspace/Controllable
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
Caused by: java.lang.ClassNotFoundException
at RJavaClassLoader.findClass(RJavaClassLoader.java:383)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 2 more
followed by
> model.path <- file.path("models", "Sample Models", "Earth Science", "Fire.nlogo")
> NLLoadModel(file.path(nl.path,model.path))
Error in .jcall(nl.obj, "V", "loadModel", .jnew("java/lang/String", model.path)) : 
  RcallMethod: invalid object parameter

And this where I have become stuck. If there can be assistance here that will be greatly appreciated. 

Cheers,
Paul






Volker Grimm

unread,
Feb 20, 2021, 2:53:42 AM2/20/21
to Paul Christoph, netlogo-users

Hi Paul,

 

I am sorry to say that RNetLogo is – in contrast to the R-Extension – no longer maintained. I suggest you try the package “nlrx”: https://besjournals.onlinelibrary.wiley.com/doi/full/10.1111/2041-210X.13286.

 

Cheers,

 

Volker

--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/4edfb48c-aa0c-44d5-97e6-ba192c538889n%40googlegroups.com.

Paul Christoph

unread,
Feb 22, 2021, 4:41:08 PM2/22/21
to netlogo-users
Update:
I have updated to Netlogo 6.2.0.  I have now noticed a java subfolder with netlogo.jar files, I saw somewhere else where I need to link to .jar files but I tried a few WDs with that as well and that did not do the trick

Aaron Andre Brandes

unread,
Feb 23, 2021, 10:55:45 AM2/23/21
to Paul Christoph, netlogo-users

Hi Paul,

We are sorry you have encountered this issue.

As noted by Volker, Rnetlogo is not currently being maintained.

If you want to try out the R extension, it can be set up to work on Windows 10 environments.  Detailed instructions follow.

Based on what you have written, you have probably completed most of these steps.

 

The key steps once everything is downloaded and updated are:

  • Edit the user.properties file
  • Edit the System Environment Variable “Path”

These steps have bold headers below

 

Here are the full  instructions for installing R and configuring it with the extension.

Pay particular attention to the Windows-specific installation steps

 

Here are the specific steps I took get the R extension running on Windows 10.

 

Install R and R packages

I downloaded R 4.0.4 for Windows  and ran the installer with default options plus installing a desktop icon.

I opened R by double clicking the desktop icon.

I typed

install.packages("rJava")

For installation of the packages I accepted the default local location, and chose a mirror site for downloading

Next

install.packages("JavaGD") # Optional

install.packages("CommonJavaJars") # Optional

 

Collect system information

I collected the necessary system information

R.home(component = "home")

[1] "C:/PROGRA~1/R/R-40~1.4"

 

system.file("jri", package = "rJava")

[1] "C:/Users/MyName/Documents/R/win-library/4.0/rJava/jri"

 

 Install the Microsoft Visual C++ 2013 if you don’t have it

I tried the Microsoft Visual C++ 2013 redistributable download

 

And chose the installer vcredist_x64.exe

I double clicked on the installer. Because Microsoft Visual C++ 2013 had been previously installed, the Installer options were “modify setup” and “repair.”

I therefore quit the installer, but you should proceed if it offers to install the software.

 

Edit the user.properties file

Note: I have substituted “MyName” for my actual username throughout this email, and you should substitute in your username when making the changes.

The one discrepancy I ran into is that there was no file C:\Users\MyName\AppData\Roaming\NetLogo\6.2\r\user.properties

The directory existed but was empty.

 

You can download the user.properties file I have attached to the folder  C:\Users\MyName\AppData\Roaming\NetLogo\6.2\r

 

You should then edit the following lines to reflect your name and R installation. (You might be able to edit directly in NotePad because I already did the step of opening and saving with WordPad.)

 

r.home=C:/PROGRA~1/R/R-40~1.4

jri.home.paths=C:/Users/MyName/Documents/R/win-library/4.0/rJava/jri

r.lib.paths=C:/Users/MyName/Documents/R/win-library/4.0

 

Edit the System Environment Variable “Path”

After that you need to edit your system environment variable Path

Use the New button to add the line (adapted if necessary)

C:\Program Files\R\R-4.0.4\bin\x64\

 

You will need to log in and out of Windows, or do a restart for the environment variable change to take effect.

 

Please note that NetLogo extensions are usable “out of the box.” The R extension requires an atypical number of configuration steps.

 

Please let us know if this leads to success, or if you need more help write us and include details of steps that have not worked, and error messages you have seen.

 

Aaron

 

-- 

Aaron Brandes, Software Developer

Center for Connected Learning and Computer-Based Modeling

--

You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.

user.properties

Paul

unread,
Feb 23, 2021, 3:22:54 PM2/23/21
to netlogo-users
Thank you both.  I did not mean to get a second response, my update was sent before Volker's response but approved/posted thereafter.  I did post a more simple question regarding the fire model - which I think has a easier solution.
Cheers
Reply all
Reply to author
Forward
0 new messages