"R script does not provide results if init library in script"

B_B_ MemberPosts:70Guru
edited May 2019 inHelp
I've developed a script in R and am trying to get it to run in RM.

I don't get any output and it seems to be related to initializing the R library I need (psych). The results are Unknown R type. If I comment out the library as in this example, the script output is delivered to RM. Psych is already installed in R.

RM is up to date and I'm using Win 7 x64, R 2.12.








<运营商激活= " true "类= compati“过程”bility="5.1.003" expanded="true" name="Process">


























Tagged:

Answers

  • keithkeith MemberPosts:157Guru
    That's strange. Your script ran fine for me (XP64, R-2.12.1), getting the same result whether library(psych) was commented out or not..

    Are there multiple versions of R installed on that machine? Is is possible that the psych package isn't installed in the R installation that RM is accessing?

    Keith
  • B_B_ MemberPosts:70Guru
    Thanks for the info Keith.

    I tired XP64 and R 2.12.2 and the script works correctly commented out or not. I tried the psych library on two Win7 machines and it failed on both of them when library(psych) was uncommented.

  • keithkeith MemberPosts:157Guru
    Strange. I don't have a Win7 box to test it on at the moment, so not sure what the differences would be.

    Pardon the really obvious questions, but just to make sure we're not overlooking something silly,,,

    1) Does the script work when you run it in standalone R on the same Win7 machines?
    2) There are no other versions of R installed on those machines?
    3) Have you gotten a very basic R script to work in RM (i.e. one that loads no external libraries).
    4) Are R and RM both either 32-bit or 64-bit (but not mixed where one is 32 bit and the other is 64 bit)?

    Keith




  • B_B_ MemberPosts:70Guru
    I developed the script first in R then moved it to RM. Narrowed it down to the library being called. Basic scripts in win 7 that don't call the library work -
    library(igraph) fails while ##library(igraph) generates an output.

    All 3 machines are running 64 bit R 12.2 with common RHOME, x64 paths, etc.

  • landland RapidMiner Certified Analyst, RapidMiner Certified Expert, MemberPosts:2,531Unicorn
    Hi,
    我现在很困惑:最终diagnosis? Does it work? Doesn't it? Depending on what?

    Greetings,
    Sebastian
  • keithkeith MemberPosts:157Guru
    I think B. is still having problems. But it sounds like the script works in standalone R on the same machine where it's failing in RM, which eliminates a bunch of the possible causes I had in mind.
  • B_B_ MemberPosts:70Guru
    Sebastian,

    The R script did not run under Windows 7 unless I commented out library(psych) -i.e., ## library(psych). I also tried it with the igraph library. It returns an unknown R type.

    It does work correctly under XP.

    Install a R library, then try this script in a R Execute Script operator. Set Results/Edit List to x, as a generic R output.

    library(libname)
    x <- 5
    output: R Result
    No Description available: Unknown R Type


    then try

    ##library(libname)
    x <- 5

    output: R Result
    [1] 5


    The full script I created works correctly in R on Win 7 and XP and in RM on XP, but fails in RM on Win 7.


    B.
  • keithkeith MemberPosts:157Guru
    OK, I just installed R 2.12-2 (x64) and RM 5.1.004 (x64) on my Window 7 Ultimate (x64) box at home.

    I ran the following process. Note that I added a print(search()) to show which packages were loaded:







    <运营商激活= " true "类= compati“过程”bility="5.1.004" expanded="true" name="Process">
























    It appears to have worked for me. In the results view, I see a Generic R Result with the value of 115. I don't see anything about an Unknown R type.
    I show the following log messages. Note that the first Execute Script (R) line indicates that igraph and psych are loaded:
    Mar 20, 2011 4:07:45 PM INFO: Saved process definition at '//LocalRepository/TestR'.
    Mar 20, 2011 4:07:45 PM INFO: No filename given for result file, using stdout for logging results!
    Mar 20, 2011 4:07:45 PM INFO: Loading initial data.
    Mar 20, 2011 4:07:45 PM INFO: Process //LocalRepository/TestR starts
    Mar 20, 2011 4:07:47 PM INFO: Execute Script (R): [1] ".GlobalEnv" "package:igraph" "package:psych"

    Mar 20, 2011 4:07:47 PM INFO: Execute Script (R): [4] "package:JavaGD" "package:stats" "package:graphics"

    Mar 20, 2011 4:07:47 PM INFO: Execute Script (R): [7] "package:grDevices" "package:utils" "package:datasets"

    Mar 20, 2011 4:07:47 PM INFO: Execute Script (R): [10] "package:methods" "Autoloads" "package:base"

    Mar 20, 2011 4:07:47 PM INFO: Saving results.
    Mar 20, 2011 4:07:47 PM INFO: Process //LocalRepository/TestR finished successfully after 2 s
    Environment variables:

    PATH containsD:\Program Files\R\R-2.12.2\bin\x64
    R_HOME=D:\Program Files\R\R-2.12.2
    JAVA_HOME=D:\Program Files\Java\jre6

    RM setting rapidminer.r.native.lib =D:\Program Files\R\R-2.12.2\library\rJava\jri\x64\jri.dll
    R Extension version is 5.1.002

    Seems like something is different between our configurations, but I'm not sure what. What happens if you try typing in your script line by line into the interactive R Console view inside RM (i.e. not R standalone, but within RM). In particular, what happens when you type the library() statement? If it appears to work, what it returned when you type "search()" to see what packages are actually loaded?

    Keith
  • B_B_ MemberPosts:70Guru
    Keith,

    Thanks for taking time to check on your Win 7 setup. I really appreciate it.

    From your comments and searching, it turns out my R user library is installed in C:\Users\........ and not in the C:\Programs folders.

    After setting the R_LIBS_USER variable to the correct folder in c:\users the script runs now.

    From this thread for R: Where does R look for library packages
    http://www.mail-archive.com/[email protected]/msg124800.html
    "...personal library directory, you need to set the environment variable R_LIBS_USER"

    Sebastian,

    Checking and setting the R_LIBS_USER is one more thing to suggest when someone can't get R working correctly with RM.

    B.
  • pmarspmars MemberPosts:1Contributor I
    R will install libraries in an user directory if it has no writing access to the program directory, e.g. C:\Program Files\R\library

    You can also change the R program directory access settings right after installation and before installing new libraries.
Sign InorRegisterto comment.