loading r-package, using r-extension

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

loading r-package, using r-extension

NetLogo-Users mailing list
Hi.
 I am making a model using r-extension ("extensions [r]")
 It works well except loading packages.
 

 For example, r:eval "library(spatstat)".
 The error message said it cannot find the package.
 In the java console, I can find the same error message.
 But, I have no problem to use R and load new packages in the Windows command prompt.

 

 I also checked my system with rsystemcheck.
 "Check Java" showed "Java version mismatch"
 But I tried to use JAVA in the Netlogo folder, but I had the same message.
 

 Regardless of this message, r-extension works except loading a package.
 I googled it, and found others had the same problem, but there are no solution.

 If anyone has a solution, please let me know.
 

 FYI, I use Window 8.1(64bit). I am using 34bit R and Java. Of course, I tried to change 64bit version for R and Java, but nothing changed.
 

 In addition, I used RNetlogo which is using rJava as well. It works well for all my purposes.

 But you know it is slow and not a looking-good model, compared to r-extension.
 

 So I prefer using r-extension.
 

 Thank you.
 

 

Reply | Threaded
Open this post in threaded view
|

Re: loading r-package, using r-extension

NetLogo-Users mailing list
Hi. Since nobody has answered my question, I just want to share my solution.
 

 I did not find a way to load r package under r-extension, yet.
 But I just used another way.
 First of all, make a function you want to run in R, and create r-script file for your function.
 In r-extension, we can load the r-script file without any error.
 

 Now, you can use R for your function in your Netlogo model.
 

 Anyway, if you find any solution for my problem, please let me know
 

 Thank you.
 

---In [hidden email], <youngjoon5@...> wrote :

 Hi.
 I am making a model using r-extension ("extensions [r]")
 It works well except loading packages.
 

 For example, r:eval "library(spatstat)".
 The error message said it cannot find the package.
 In the java console, I can find the same error message.
 But, I have no problem to use R and load new packages in the Windows command prompt.

 

 I also checked my system with rsystemcheck.
 "Check Java" showed "Java version mismatch"
 But I tried to use JAVA in the Netlogo folder, but I had the same message.
 

 Regardless of this message, r-extension works except loading a package.
 I googled it, and found others had the same problem, but there are no solution.

 If anyone has a solution, please let me know.
 

 FYI, I use Window 8.1(64bit). I am using 34bit R and Java. Of course, I tried to change 64bit version for R and Java, but nothing changed.
 

 In addition, I used RNetlogo which is using rJava as well. It works well for all my purposes.

 But you know it is slow and not a looking-good model, compared to r-extension.
 

 So I prefer using r-extension.
 

 Thank you.
 

 



Reply | Threaded
Open this post in threaded view
|

Re: loading r-package, using r-extension

jcthiele
In reply to this post by NetLogo-Users mailing list
Hi,

here are some ideas how to find and solve the problem with package loading using the r-extension:

Make sure, you installed the required package correctly. Is it available in a pure R session? Was it installed in another R version or as administrator? Check, in which directory you have installed the package.

If you're clear about these points, go back to NetLogo.
Now, I would start the interactiveShell:
Type r:interactiveShell into NetLogo's Command Center.
Type ".libPaths()" in the interactiveShell and submit (press Ctrl+Enter).
This will show the libPaths used by the underlying R session for loading packages. Check if the loaded package is really installed under one of these paths.
If not, you could install it again through the interactiveShell by typing install.packages("spatstat") into the interactiveShell and submitting the command (Ctrl+Enter).
Another option is to add a path, where the required package is installed, for example:
.libPaths(c("C:/Users/<username>/Documents/R/win-library/3.2",.libPaths()))

You can also include this command into your NetLogo model, e.g.
r:eval ".libPaths(c("C:/Users/<username>/Documents/R/win-library/3.2",.libPaths()))"

You can also try to set an environment variable R_LIBS_USER with the required path.

Hope this helps.
Good luck.

All the best,
Jan


Reply | Threaded
Open this post in threaded view
|

Re: loading r-package, using r-extension

BrookJon
In reply to this post by NetLogo-Users mailing list
Hi:

I saw you using R script for loading the R package.  May I ask the way of
how to load the R script´╝č Because I can load the R package, but can't
connect the R script. There is always  a error:  error in file(filename,
"r", encoding = encoding) :
  cannot open the connection.

Thank you very much



--
Sent from: http://netlogo-users.18673.x6.nabble.com/