Hi everyone, a few months back I struggled to get R working with KNIME, and in the end gave up, but on getting myself a new laptop I thought I’d try again… And with a fair amount of effort I finally succeeded!
In the hope it may save someone else some time, below are the steps that worked for me. I’d also like to say the following topic really helped me along the way:
Install R alongside KNIME on Windows and MacOS
- Install R. This is available from www.r-project.org and as of Apr 2020 the latest version was 3.6.3
- Install RStudio. This may not strictly be necessary, but it is a superb IDE, as is available from https://rstudio.com
- Install Rtools. Rtools is typically used to build your own R packages, but it is also needed to install the latest Rserve package, which itself is needed to run R in KNIME.
- Rtools is available from https://cran.r-project.org/bin/windows/Rtools/
- Rtools needs to be installed in the root of the C Drive (ie. C:\Rtools)
- Install the Rserve package.
- Open R or RStudio and in the console type:
- This will then install the Rserve package into your User Library. If you do not know where this is type .libPaths() or in RStudio go to: Tools | Install Packages… You will then find the user directory in the Install to Library drop-down
- Once installed, check you have the latest version - as of Apr 2020 KNIME needed 1.8.6 - by typing into the console:
- KNIME only seems to recognises Rserve if it is loaded into the System library, usually located in “C:\Program Files\R\R-3.6.3\library”, so copy the Rserve folder from your User Library folder, and place it here
- Open up KNIME and install the “KNIME Interactive R Statistics Integration” extension through File | Install KNIME Extensions…
- Once installed, go to File | Preferences | KNIME | R and you’ll be asked to point it to RHome. RHome is likely to be located in a folder similar to:
Using R in KNIME:
It became immediately clear to me that there’s a number of different ways you could use R in KNIME, from pretty much building workflows solely using R nodes, to having discreet sections of the workflow using R, to just having the odd R Snippet node amongst an otherwise standard KNIME workflow. The attached R_Intro_1.knar gives very basic examples of some of these.
R_Intro_1.knar (30.4 KB)
I hope this will be of help. Now it’s time for me to actually make the most of it!!!