R Snippet Error

Is there a tutorial on using R Snippet nodes that proceeds step-by-step through calling libraries and executing code?

I have a persistent error that probably has a simple fix but can’t seem to work through.

Thanks,

John

You might want to make sure you have the latest versions of KNIME, R and Rserve installed (yes you will need the version 1.8.6).

Unfortunately that can be a bit of an effort.

RServe 1.8.6 on MacOSX

RServe 1.8.6 on Windows

R and Rtools

2 Likes

Just installed Rserve 1.8.6 manually. Seems not to have changed the functionality. Maybe this is just a period of incompatibility with Knime/R/Rserve? Which we all know happens occasionally…

To be honest I do not think this is the case. Could you check if your configurations are up to date. And are all R Snippets are affected or is it just a specific one. And did you use the ‘official’ ones or the ones from the community noes? (Recommendation is to use the official ones).

Maybe you can tell us more about your setup, your OS. You might just run the workflow from the hub (previous entry) to determine the R settings.

1 Like

Rechecked for updates to R on KNIME, seems good there.

I’m using the official nodes, but the problem affects all of them.

Rserve is, indeed, 1.8.6.

I’m running KNIME on a MacBook with Catalina10.15.3. R version is 3.6.2.

When I try to run the R version workflow (above) the error I described prevents me. If I press ‘Eval Code’ in the node I get the following:

Thanks - John

Next steps would be to create a minimal example where the error occurs and load that to the this thread along with a complete log from KNIME.

Also you might use the results of this workflow. After you installed the package “sessioninfo” in your regular R/RStudio.

1 Like

In the past we have seen errors like this pop up when using using a variable name that conflicts with a reserved value in the workspace. For example, using a variable called ‘F’, which can also represent a value of ‘FALSE’ when used as a parameter. In this specific example, there was a bug on our side that needed fixing.

If you can, it would be helpful to post a minimal example workflow that reliably reproduces the problem so we can investigate. Then, if it is indeed a bug, we can put in a ticket and get it squashed :slight_smile:

1 Like

Somewhat clunky response but below is a link to a RSnippet workflow that - for me - doesn’t work and throws the errors I’ve provided screenshots of.

Also below is the output from running the sessioninfo package in R. Note, Rserve only says 1.7-3.1, but I did install 1.8.6 from file.

How do I generate a complete .log file in KNIME?

knime://My-KNIME-Hub/Users/jcmargeson/Public/RSnippetTest

Blockquote─ Session info ──────────────────────────────────
setting value
version R version 3.6.2 (2019-12-12)
os macOS Catalina 10.15.3
system x86_64, darwin15.6.0
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/Montreal
date 2020-03-09

Blockquote─ Packages ──────────────────────────────────────
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
cli 2.0.2 2020-02-28 [1] CRAN (R 3.6.0)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.0)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)
curl 4.3 2019-12-02 [1] CRAN (R 3.6.0)
fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.0)
forecast * 8.11 2020-02-09 [1] CRAN (R 3.6.0)
fracdiff 1.5-1 2020-01-24 [1] CRAN (R 3.6.0)
ggplot2 3.3.0 2020-03-05 [1] CRAN (R 3.6.2)
glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0)
gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.0)
lattice 0.20-38 2018-11-04 [1] CRAN (R 3.6.2)
lifecycle 0.2.0 2020-03-06 [1] CRAN (R 3.6.2)
lmtest 0.9-37 2019-04-30 [1] CRAN (R 3.6.0)
magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)
munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.0)
nlme 3.1-142 2019-11-07 [1] CRAN (R 3.6.2)
nnet 7.3-12 2016-02-02 [1] CRAN (R 3.6.2)
pillar 1.4.3 2019-12-20 [1] CRAN (R 3.6.0)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.0)
quadprog 1.5-8 2019-11-20 [1] CRAN (R 3.6.0)
quantmod 0.4-15 2019-06-17 [1] CRAN (R 3.6.0)
R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.0)
Rcpp 1.0.3 2019-11-08 [1] CRAN (R 3.6.0)
rlang 0.4.5 2020-03-01 [1] CRAN (R 3.6.0)
Rserve * 1.7-3.1 2019-04-15 [1] CRAN (R 3.6.0)
rstudioapi 0.11 2020-02-07 [1] CRAN (R 3.6.0)
scales 1.1.0 2019-11-18 [1] CRAN (R 3.6.0)
sessioninfo * 1.1.1 2018-11-05 [1] CRAN (R 3.6.0)
tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.0)
timeDate 3043.102 2018-02-21 [1] CRAN (R 3.6.0)
tseries 0.10-47 2019-06-05 [1] CRAN (R 3.6.0)
TTR 0.23-6 2019-12-15 [1] CRAN (R 3.6.0)
urca 1.3-0 2016-09-06 [1] CRAN (R 3.6.0)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0)
xts 0.12-0 2020-01-19 [1] CRAN (R 3.6.0)
zoo 1.8-7 2020-01-10 [1] CRAN (R 3.6.0)

1 Like

I downloaded your workflow to check it - thanks for uploading it to the Hub.

I think the problem is that the output of your R Snippet is a factor rather than a data frame. When I coerce the output using

knime.out <- as.data.frame(df)

it works for me. Can you verify?

2 Likes

hi @jcmargeson

You will find log file on following location ...\knime-workspace\.metadata\knime\knime.log

Also you can get it from within KNIME. Go View --> Open KNIME log

To change level of logging go from within KNIME File --> Preferences --> KNIME

Br,
Ivan

Log file is attached.

Scott, I suspected my unfamiliarity is part if this :slight_smile: and need to read more about how the R and Python nodes work in KNIME. Originally, I was hoping there was a single resouce on that.

When I reformatting the knime.out as data.frame, the same errors appeared:

ERROR: Could not execute internal command.ERROR: R evaluation failed.: "sapply(ls(),function(a)class(get(a,envir=globalenv()))[1])"ERROR: R evaluation failed.: "sapply(ls(),function(a)class(get(a,envir=globalenv()))[1])"ERROR: eval failed

Then as I tried to evaluate the script:

ERROR: Could not capture output of command.ERROR: R evaluation failed.: "knime.stdout.con<-textConnection(‘knime.stdout’,‘w’);knime.stderr.con<-textConnection(‘knime.stderr’,‘w’);sink(knime.stdout.con);sink(knime.stderr.con,type=‘message’)"ERROR: R evaluation failed.: "knime.stdout.con<-textConnection(‘knime.stdout’,‘w’);knime.stderr.con<-textConnection(‘knime.stderr’,‘w’);sink(knime.stdout.con);sink(knime.stderr.con,type=‘message’)"ERROR: voidEval failedERROR: Transferring the R script to R failed.ERROR: R evaluation failed.: "knime.tmp.script"ERROR: assign failedERROR: Could not capture output of command.ERROR: R evaluation failed.: "sink();sink(type=‘message’)
close(knime.stdout.con);close(knime.stderr.con)
knime.output.ret<-c(paste(knime.stdout,collapse=’\n’), paste(knime.stderr,collapse=’\n’))
knime.output.ret"ERROR: R evaluation failed.: "sink();sink(type=‘message’)
close(knime.stdout.con);close(knime.stderr.con)
knime.output.ret<-c(paste(knime.stdout,collapse=’\n’), paste(knime.stderr,collapse=’\n’))
knime.output.ret"ERROR: eval failedERROR: Could not cleanup after command execution.ERROR: R evaluation failed.: "rm(knime.tmp.ret,knime.output.ret,knime.stdout.con,knime.stderr.con,knime.stdout,knime.stderr)"ERROR: R evaluation failed.: "rm(knime.tmp.ret,knime.output.ret,knime.stdout.con,knime.stderr.con,knime.stdout,knime.stderr)"ERROR: voidEval failedERROR: Could not execute internal command.ERROR: R evaluation failed.: "dev.off()"ERROR: R evaluation failed.: "dev.off()"ERROR: eval failedERROR: Could not execute internal command.ERROR: R evaluation failed.: "ls()"ERROR: R evaluation failed.: "ls()"ERROR: eval failed

Do other users report R version issues similar to mine on Mac OS? Are these nodes more stable on Windows?

In the meantime, I’m working through possible solutions from this thread:

Do you know if anything worked at that time?

some ideas:

  • you should make sure to have Rserve 1.8.6 - it does not show up on your configuration so the installation might not have been successful
  • I do not see the Cairo package which is also needed
  • you should check if KNIME does point to the right installation of R and not another version you might have on your machine

At the bottom of this hub workflow, there are links to relevant articles. You might get some ideas there

Then you could toy around with advanced settings although I doubt that that would help - you might try nonetheless

When reinstalling Rseve 1.8-6 from tar.gz file this error occurs:

*** Rserve requires R (shared or static) library. ***
*** Please install R library or compile R with either --enable-R-shlib ***
*** or --enable-R-static-lib support ***

Does this affect any functionality?

It very much sounds like the version 1.8.6 has not been properly installed as the session info suggested. Unfortunately, this does affect the functionality.

As I understand KNIME is working on a solution but until then you will have to compile it yourself since there are no pre-compiled versions available.

The linked articles (1) would still be relevant. As well as this thread:

Maybe @Mark_Ortmann could advise us as to when we might be able to expect the blog entry dealing with the Rserve and MacOSX compiling problem (that sometimes compiling does not work or needs a lot of effort)

@mlauber71,

we’re currently working on a proper R documentation and mainly on the FAQ/Trouble shooting part :), but it will still need some more time.

@jcmargeson,
just sent you the script we’re using to get R setup on Catalina please check your private messages and excuse all the trouble we’re causing you due to missing documentation.

Best
Mark

3 Likes

I’m facing a similar issue with MacOS Catalina and Rserve 1.8.6 install, the error description and log of which I posted in another thread:
https://forum.knime.com/t/errno8/13567/17?u=longoka

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.