The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
"R script does not provide results if init library in script"
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.
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.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.1.003">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.1.003" expanded="true" name="Process">
<process expanded="true" height="431" width="614">
<operator activated="false" class="read_csv" compatibility="5.1.003" expanded="true" height="60" name="Read CSV" width="90" x="45" y="75">
<parameter key="csv_file" value="d:\Data\test_pca_data-rm.txt"/>
<parameter key="column_separators" value="\t"/>
<parameter key="use_quotes" value="false"/>
<list key="annotations"/>
<list key="data_set_meta_data_information"/>
</operator>
<operator activated="false" class="r:export_data" compatibility="5.1.002" expanded="true" height="60" name="Export Example Set" width="90" x="227" y="86"/>
<operator activated="false" class="normalize" compatibility="5.1.003" expanded="true" height="94" name="Normalize" width="90" x="112" y="300"/>
<operator activated="true" class="r:execute_script_r" compatibility="5.1.002" expanded="true" height="76" name="Execute Script (R)" width="90" x="313" y="255">
<parameter key="script" value="##library(psych) dataout <- as.data.frame(9) x <- 5 y <- 23 z <- x * y dataout <- z "/>
<enumeration key="inputs"/>
<list key="results">
<parameter key="dataout" value="Generic R Result"/>
</list>
</operator>
<connect from_op="Execute Script (R)" from_port="output 1" to_port="result 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>
Tagged:
0
Answers
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
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.
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
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.
I'm quite confused now: What was the final diagnosis? Does it work? Doesn't it? Depending on what?
Greetings,
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.
I ran the following process. Note that I added a print(search()) to show which packages were loaded: 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: Environment variables:
PATH contains \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 = \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
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/r-help@r-project.org/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.
You can also change the R program directory access settings right after installation and before installing new libraries.