Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
No replies
ttsuzuku
ttsuzuku
2 Posts
ACCEPTED ANSWER

Pinned topic How to use high level R commmand in Jaql scripts with R module

‏2013-05-10T05:37:25Z |

Does anyone know how to use high level R commmand that has 2 or more lines in their outputs in Jaql scripts with R module?
 

On Information Center, I found sample code that seems to have only 1 array data as output.
http://pic.dhe.ibm.com/infocenter/bigins/v2r0/index.jsp?topic=%2Fcom.ibm.swg.im.infosphere.biginsights.analyze.doc%2Fdoc%2Fr0057925.html

R::externalRFn ( rFunction = '( function( x )
  { data.frame(c(x,x+1),c(x+2,x+3)) } )',
  parameters = schema { x: long },
  result = schema [{first:long, second:long}*] );


I want to use some high level R commands such as "cor.test" and "summary" in Jaql R module, but couldn't find how to return these complex text lines from R to Jaql stream.

# R sample commands (cor.test and summary)
# these command have 2 or more lines in their outputs

> x=c(11,31,32,20,25,43,14)
> y=c(0.1,0.4,0.3,0.2,0.4,0.5,0.1)
> cor.test(x,y)

        Pearson's product-moment correlation

data:  x and y
t = 5.2393, df = 5, p-value = 0.003356
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 0.5422575 0.9882904
sample estimates:
      cor
0.9197389

> summary(x)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  11.00   17.00   25.00   25.14   31.50   43.00

I think that the schema of "result" in R::externelRFn might not be available for these complex text outputs.