sse-r-plugin
sse-r-plugin copied to clipboard
Error while using R.ScriptEval()
Description
I am using R.ScriptEval()
to perform clustering analysis using a source R file and assign colors to data points.
From plugin console, I can see that:
- I connected to R plugin
- Successfully executed the R script
- But failed to receive response from plugin
Steps to Reproduce
expression in in Qlik to assign color to data points in a scatter plot
R.ScriptEval('source("/path/POC_Predict.R")', [param1] as param 1, [param2] as param 2, ... [paramn] as param n)
# read params passed by R.scriptEval()
# do something
# last line of the R Script
as.data.frame(response$predict)
Expected behavior
data points are colored as per the cluster index received from R
Actual behavior
Error: I see the following error in plugin console log:
2018-03-22 18:42:31.0128|INFO|SSEtoRserve.RServeEvaluator|Rserve result: 2 rows, hashid (41876889) 2018-03-22 18:42:31.0128|DEBUG|SSEtoRserve.RServeEvaluator|Rserve result column names: value, visible 2018-03-22 18:42:31.0128|DEBUG|SSEtoRserve.RServeEvaluator|Rserve result nrOfCol umns: 2 2018-03-22 18:42:31.0128|WARN|SSEtoRserve.RServeEvaluator|Rserve result, column data type not recognized: RserveCLI2.SexpList
Environment
Plugin is installed on a Windows VM
Operating system where the SSE plugin is deployed
[x] Windows
[ ] Linux
Qlik Sense
[ ] Desktop
[x] Server
Versions
- sse-r-plugin: Qlik Sense February 2018 | v1.1.0
- Qlik Sense: QS Nov 2017.
- Operating system: Windows Server 2012 R2
- [Other relevant versions] I am running R server and SSE plugin on a different VM, the sample k-mean clustering example with iris data is working fine, please let me know if you any other details.
Thanks in advance.
Hi @tobiaslindulf , Could you please help me with the above issue when you get a chance, let me know if you need more information.
Hi, thanks for reaching out for help. Interesting problem. I can think of some different things to look into:
- Do you expect as.data.frame(response$predict) to produce a data frame with 2 columns? If not then try to return just 1 column by modifying the R script.
- Can you provide a real example of how your call to R.ScriptEval('source("/path/POC_Predict.R")', [param1] as param 1, [param2] as param 2, ... [paramn] as param n) looks like. If you use spaces in the names you may get problems.
- Can you try to use the latest version of the SSEtoRServe plugin (1.2.0). It is backwards compatible with your sense version. That plugin version handles data frames from R a bit better than before.
- your script argument of source is probably not returning anything so you need to call something in that local R file as well, like a function with q as input. Also, I think you need to set the working directory to something just in case it is not set in the Rserve session. Like this: if you have a local R file named myEcho.R containing this: myEcho <- function(df) { df }
Then the R script in the expression could look like this: setwd("C:/Users/userX/Documents/R/Myscripts"); source("myEcho.R"); myEcho(q);
I hope this helps.
@tobiaslindulf , thanks for the response, I will try 1, re-check 2, try 3 and for 4: i think I can run my script stand-alone, so this should not be a problem, I will check this again and get back to you, thanks!