Install / Add new R package to KNIME

I was trying to run one of the workflow demos called “01_Example_of_R_Snippet” from the EXAMPLES (knime://EXAMPLES/) and the second node (R Source Workspace - Read Date) did not run.

I discovered that this line

library(RevoScaleR)

is the cause of the error. It seems I do not have this package. My question is how do I install this since it seems KNIME install another R.

Alternatively, how do I change this path to my R installation?

I solved a similar problem to ensure a library was installed by putting the following snippet at the start of my R code block, in this case for the sm library:

s = getOption("repos") # hard code the UK repo for CRAN
s["CRAN"] = "http://cran.uk.r-project.org"
options(repos = s)
rm(s)

install.packages("sm")
library(sm)

I think you should be able to adapt it to ensure that the relevant package is installed into the R instance which KNIME uses. I can’t remember the details as to why I needed to hardcode the UK cran repository unfortunately!

Steve

3 Likes

Or simply start the R version that comes with KNIME in cli and then install desired packages from there.

3 Likes

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