ERROR R Snippet Execute failed: Could not parse REXP

Hello, all.

Please help with some issue. In my table I have 2 fields: “first_date” and “current_date”. Also I have function “work_days_count” in postgresql database which counts number of business days between two dates.

I try to run in R Snippet next code:


drv <- dbDriver(“PostgreSQL”)
passw <- “pass”
con <- dbConnect(drv, dbname = “dbname”,
host = “”, port = 5432,
user = “user”, password = passw)

work_days <- function(row){
days <- dbGetQuery(conn = con, statement = paste0(“select work_days_count(’”, row[[“first_date”]], “’,’”, row[[“current_date”]],"’)"))
}$workdays <- apply(, 1, work_days)


knime.out <-"

It works without issues when I press button “Eval script” in R Snippet window. But when I try to execute node I get error “Execute failed: Could not parse REXP”.

Can anyone help me?

The usual questions would be which version of R and especially RServe do you use? You will need 1.8.6 and should have a current version of KNIME and R.

In the meantime you could check these discussions if they might help you.

Install R alongside KNIME on Windows and MacOS

R and Rtools

RServe 1.8.6 on MacOSX

1 Like

Hi @dbolshev,

if I may ask why using R Snippet node to connect to PostgreSQL DB and get your workdys? There is PostgreSQL Connector node and after connected you should be able apply same logic to obtain working days. Maybe could be a bit easier :wink:


1 Like


I have a long calculation of “first_date” for each row of table. But necessary data to calculate number of business days is in this DB.


I install R-3.6.2 and Rserve_1.7-3.1. I tried to install 1.8-6 using this install.packages(“Rserve”, “”, type = “source”), but it wasn’t installed:

"Warning in untar2(tarfile, files, list, exdir, restore_times) :
failed to copy ‘Rserve/src/client’ to ‘Rserve/clients’

  • installing source package ‘Rserve’ …
    ** using staged installation
    Warning in system(“sh ./”) : ‘sh’ not found
    ERROR: configuration failed for package ‘Rserve’
  • removing ‘C:/Program Files/R/R-3.6.2/library/Rserve’
    Warning in install.packages :
    installation of package ‘Rserve’ had non-zero exit status"

Well yes this is the challange before being able to use R to install RServe 1.8.6:

You would have to follow the steps or maybe @Mark_Ortmann also has a script to help with that on Windows in addition to MacOSX.

@mlauber71 and @dbolshev,

sadly we don’t have a script for windows.

@dbolshev were you able to solve your problem? Maybe you’re missing RTools?

Hello, @Mark_Ortmann.

Thanks for your answer. I haven’t solved my problem with R yet.

P.S. I have Rtools.


sorry to hear that you’re still having problems. Maybe this helps?

1 Like

Maybe I did something wrong.
But I made variable:

And when I tried to install Rserve, I got:

Hi @dbolshev -

Here you need to make sure you are editing the existing Path variable (as opposed to creating new system variables for R and Rtools).

After doing this, I was able to build Rserve on my laptop. Hope it helps.

1 Like

Yes, Thanks a lot. I’ve installed Rserve. But error still occur:
“ERROR R Snippet 2:26 Execute failed: Could not parse REXP”

P.S. Script works in RStudio

So this error points to a type mismatch. In the R Snippet node, information you plan to pass out of the node needs to be in a dataframe. This would explain why your code works in RStudio but not KNIME.

It makes me wonder if you should try to coerce your table to a dataframe right before the end of your script.

Maybe at the end try
knime.out <-

If that doesn’t work, can you identify which line in the script is causing the failure? You can execute line-by-line inside the R Snippet node to find out. I suspect it’s the last line, but it would be good to confirm.

I added to script but it didn’t help. When I push the button “Eval Script” in dialog window it hasn’t errors:

The same thing when I try to eval script by rows. But when I try to execute node I get error.


sadly I’m not able to reproduce your problem.

When you drag & drop a new R Snippet node into your workspace are you able to execute it without errors? If that works can you please do the following.

  1. Open Dialog
  2. Reset Workspace
  3. Evaluate lines 1-14
  4. Tell me what the type of is (shown in the workspace view top right)
  5. Can you see any strange entries in your knime.out data.frame?

I’m very sorry that solving this issues takes so much of your time.

Here are my thoughts.

You do a lot of things in one step. A function that calls a SQL to connect and then appends the result to the table. Even if that would be a correct syntax it might make sense to split that up and check the intermediate results (also from within the R snippet) if there are some strange results.

Then you could try and switch out the format of the output table (not sure if that would help).

As a workaround, you could try and save the results from the knime.ini file to an ARFF or Parquet file. The result could then be brought back in. as knime.out you could just provide a small data frame or the result of a flow variable or just the initial table.


I evaluated script and printed result knime.out in console:

In console all looks fine.

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