Install / Add new R package to KNIME

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