R Snippet os only working in Dialog window, but not by executing node

Hi everyone,
I am using a R-Snippet for PCA projection (library (PCAmixdata).
My code is working in the R-Snippet dialog window. So, in the workspace there is the correct knime.out ← mixData$ind$coord matrix visible. But when I try to execute the node there comes a ERROR:

ERROR R Snippet 2:186 Execute failed: R evaluation failed.: “knime.tmp.ret<-NULL;printError<-function(e) message(paste(‘Error:’,conditionMessage(e)));for(exp in tryCatch(parse(text=knime.tmp.script),error=printError)){tryCatch(knime.tmp.ret<-withVisible(eval(exp)),error=printError)
if(!is.null(knime.tmp.ret)) {if(knime.tmp.ret$visible) print(knime.tmp.ret$value)}};rm(knime.tmp.script,exp,printError);knime.tmp.ret$value”

I am operating on macOS SIERRA, Version 10.12.6

Hi JGLC,

Could you please attach the R-code you’re using?
Best,
Daria

Hi Daria,
thanks for helping out.

Please see the following R-Code:

######################################################
library(PCAmixdata)
DataNumerical <- data.frame(knime.in$“annual_inc”, knime.in$“percent_bc_gt_75”)
DataCategorical <- data.frame(knime.in$“sub_grade”, knime.in$“home_ownership”, knime.in$“emp_length”)
mixData = PCAmix(X.quanti = DataNumerical, X.quali = DataCategorical)
knime.out <- data.frame(mixData$ind$coord)
#knime.out <- DataNumerical
######################################################

Best,
Jan

Hi Jan,

The code does work for me too.
Could you maybe share the workflow (or a sample data set) you are using, so I could try to reproduce the error?
Thanks!
Daria

Hi
Please find attached a short sample data set.
Btw I am operating on macOS Sierra.
Best, Jan

test.zip (10.5 KB)

Hi Jan!

I already mentioned this per email, but for others will elaborate more on the issue here also:

The PCAmixadata package opens a window with a plot duing the PCAmix function. While this does work on Windows for this case, it is not officially supported to use the R integration in this way (as in “opening windows from R”) since it causes problems especially on Mac.

Please refer to the PCAmixdata documentation, you will find that the PCAmix() function has a parameter graph which is set to TRUE by default. If you set that to false, it should work without a problem on Mac also.

Cheers, Jonathan.

2 Likes

Hi all, it worked. Thanks Jonathan

1 Like