Skip to content

Troubleshooting R in NetLogo 6

Robert Grider edited this page Dec 22, 2016 · 3 revisions

This page offers some tips and tricks for getting the R extension working with NetLogo.

.libPaths on Windows

.libPaths doesn't properly recognize the User's libraries on Windows (this may occur on other platforms as well). If you see an error when running r:setPlotDevice, this may be the cause. To resolve, open the R GUI (not the NetLogo R interactive shell) and run .libPaths(). You should see two directory entries. One will be something like "C:/Users/Your Username/Documents/R/win-library/3.3". Now run the following code in NetLogo before calling r:setPlotDevice:

r:eval ".libPaths(\"C:/Users/Your Username/Documents/R/win-library/3.3\")"

If you integrate with other R libraries, you may need to run this command before calling require or library on them.

If you use the R Extension regularly and you want to have this command added automatically, create a file named ".Rprofile" in the NetLogo "app" subdirectory. The file's contents do the same thing as the NetLogo command, but will be run on the R environment each time it's initialized.

invisible(.libPaths("C:/Users/Your Username/Documents/R/win-library/3.3"))

If there are other R commands you would like run each time the R extension starts, you can also add those to ".Rprofile".

We hope to release a fix for this soon so that the R extension does this automatically!

Clone this wiki locally