Qlik Community

Qlik Server Side Extensions Discussions

Discussion Board for collaboration on Server-Side Extensions and Advanced Analytics Integration.

igoralcantara
New Contributor

Problem with the R Plugin

I have Sense Server November 2017 release. I have installed the R Plugin and I am able to run the R examples provided. So, apparently the plugin is working.

However, when I try to use it with my own data I am not able to make it work.

For example, if I add a text object and write the following expression, I get no result. Not even an error, just a blank text. There are absolutely no blank values.

R.ScriptEval('mean(q$BMI);', BMI)

Issue number 2:

When I try to execute an R command in the script, I get this error "Client specified an invalid argument."

This is the code. The source R file runs fine in R Studio.

TempR:

LOAD '$(vRSource)' As RSource

Autogenerate 1;

R:

NoConcatenate

LOAD

R.ScriptEvalStr('source(q$RSource);', RSource) as R_Output

Resident TempR;

Tags (1)
1 Solution

Accepted Solutions
akarolewski
New Contributor III

Re: Problem with the R Plugin

1. As I noticed in all examples when they indicate data they write like this: BMI as bmi. I am  not sure if it matters but if there are no other ideas I would try.

2. For aggregations you need to use aggregate versions of the function:

R.ScriptAggr('mean(q$BMI);' BMI as BMI)

3. You need to be careful when using Str version of the function and passing numerical data. Maybe you could use:

R.ScriptEvalExStr('N', 'source(q$RSource);', RSource as RSource)

4 Replies
akarolewski
New Contributor III

Re: Problem with the R Plugin

1. As I noticed in all examples when they indicate data they write like this: BMI as bmi. I am  not sure if it matters but if there are no other ideas I would try.

2. For aggregations you need to use aggregate versions of the function:

R.ScriptAggr('mean(q$BMI);' BMI as BMI)

3. You need to be careful when using Str version of the function and passing numerical data. Maybe you could use:

R.ScriptEvalExStr('N', 'source(q$RSource);', RSource as RSource)

tln
New Contributor II

Re: Problem with the R Plugin

For Issue number 2:

Qlik always expect some value to be returned from SSE and actually the source R function does not return anything unless the parameter echo = TRUE.

So the following should work for you:

R.ScriptEvalStr('source(toString(q$RSource[1]), echo = TRUE);', RSource) as R_Output

Highlighted
igoralcantara
New Contributor

Re: Problem with the R Plugin

Is there any documentation for these R.Script functions?

ost
New Contributor III

Re: Problem with the R Plugin

Hi Igor!

Yes, the documentation can be found here server-side-extension/writing_a_plugin.md at master · qlik-oss/server-side-extension · GitHub

Regards,

Josefine

Community Browser