Exit code 4 when using R node

I have a Knime workflow that works perfectly fine through the GUI.
But when i do a command line execution, I keep getting the exit code 4 error:

This is my command line execution code:

knime -nosave -reset -application org.knime.product.KNIME_BATCH_APPLICATION -workflowDir=“C:\DATA\knime-workspace\FG_file_consumption_check”

I understand that Exit code 4 means there was an error during execution.
This is my original KNIME workflow:

By process of elimination, I rand the command line script after removing each node 1 by 1 from the end. I found that if I remove the R nodes then it executes successfully.

Is there any way to make the command line execution work with the R nodes? I’m trying to automate the execution, and I don’t want to keep opening KNIME manually and executing the workflow.
Any insight would be appreciated!

Thank You

So I found out that its due to me calliing these libraries in my R code:

library(plyr)
library(dplyr)
library(lubridate)
df <- knime.in

df$PHX_lot_id <- as.character(df$PHX_lot_id)
df$fg_lot_id <- as.character(df$fg_lot_id)
df$check <- ifelse(df$PHX_lot_id==df$fg_lot_id, "yes","no")
df1<-df %>% filter(check=="no")

If I try just executing without the libraries by taking converting the table to an R dataframe and back to a table again, its fine. So its not the R node per say, but Knime trying to call R libraries from the command line execution.
has anyone done this before?

@thentangler these things come to my mind.

You should check if you can do these transformations in knime so you would not need to use R.

Then you could try and use R thru Miniconda and Conda Environment Propagation.

Then you might want to check a complete log file to see what is going on.

Also there are hints that this might be a thing about the lubridate package specifically.

Hi @mlauber71
The R code I showed was just the first few lines that i truncated for testing. The actual R code is a bit longer. If I were to convert it to KNIME it would blow up the flow and make it very complicated.

Could you advise where I can find the complete log file that is generated when I execute in batch mode?
Thank You

@thentangler I do not have a consitant guide how to obtain the batch log. You should check out some threads in the forum about that.

Currently I would assume the problem might be with the R lubridate library. What version of R are you using?

You could try and use the community R nodes, but that would mean you have to have R with Rserve running when knime is being started. Never tried that with a batch system.

My R version is 4.1.3

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