Topic
  • No replies
ttsuzuku
ttsuzuku
2 Posts

Pinned topic 2 array data cannot be processed on Jaql with R module

‏2013-05-10T05:17:05Z |

I cannot run my jaql script with R module correctly. Does anyone know how to use 2 or more array data as input to R::externalRFn command?

jaql> import R;
jaql> meanR2 = R::externalRFn( rFunction = '(function(x,y) data.frame(c(mean(x),mean(y))))',parameters = schema {data1: [ * ], data2: [ * ] },result = schema [double*]);

jaql> TEMP=[29,29,30,32,33,32,31,26,28,31];
jaql> CUST=[326,364,283,369,417,436,438,296,263,389];

#NG case 1
jaql> [TEMP,CUST] -> meanR2();
encountered an exception during the evaluation of a statement
java.lang.IllegalArgumentException: In call of External UDFnull:missing value for parameter: data2

#NG case 2
jaql> {TEMP,CUST} -> meanR2();
encountered an exception during the evaluation of a statement
java.lang.IllegalArgumentException: In call of External UDFnull:missing value for parameter: data2

#NG case 3
jaql> {TEMP,CUST} -> meanR2($.TEMP,$.CUST);
parse error: java.lang.IndexOutOfBoundsException: variable is not defined: $
Ignoring input until semicolon ';' ...
encountered an exception during the evaluation of a statement
java.lang.IndexOutOfBoundsException: variable is not defined: $

#OK case
jaql> meanR2(TEMP,CUST);
[
  30.1,
  358.1
]

But, I'd like to use my meanR2() at the end of Jaql process stream (connected with "->").