# Install R alongside KNIME on Windows and MacOS

**URL:** <https://forum.knime.com/t/install-r-alongside-knime-on-windows-and-macos/13287>\
**Category:** Knowledge sharing\
**Created:** [January 26, 2019, 9:42am UTC](https://forum.knime.com/t/install-r-alongside-knime-on-windows-and-macos/13287 "2019-01-26T09:42:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [January 26, 2019, 9:42am UTC](https://forum.knime.com/t/install-r-alongside-knime-on-windows-and-macos/13287/1 "2019-01-26T09:42:35Z")

</div>

Over the last months I have collected a few entries about the installation of [R](https://www.r-project.org) alongside KNIME that contain some maybe useful hints how to overcome certain obstacles while installing them. I want to bring them together here. (If you are looking for a basic guide about how to install R in the first place you might look [here](https://medium.com/@GalarnykMichael/install-r-and-rstudio-on-windows-5f503f708027) or [here](https://www.dummies.com/programming/r/how-to-install-r/)).

A few maybe unnecessary remarks upfront. Yes it takes some effort to get KNIME and R up and running but in the end you will be rewarded with the whole world of possibilities R has to offer, and you will be able to solve some tasks that you were not able to easily solve before while having the power of the workflow concept of one of the leading Data Scientist platforms at you fingertips.

OK first there are two ‘flavours’ of R you can install, on Windows the integrated Binaries (KNIME would manage all of R) or you get yourself a standalone version of R ( **which I strongly recommend** , and I recommend using the 64 Bit version wherever possible). Alongside that I recommend installing [RStudio](https://www.rstudio.com) to easily manage R and that can also be useful in itself. To work with KNIME R needs several packages most prominently **RServe** (we come to that in a minute) and **[Cairo](https://forum.knime.com/t/add-table-to-r-r-cannot-be-initialized-r-home-is-invalid/9851/2)**. But you will be able and have to install further libraries as your tasks evolve.

> [@Importing R Code in Knime](https://forum.knime.com/t/importing-r-code-in-knime/11260/3):
>
> There are two basic possibilities to use R with KNIME you have a R version on your computer and you point KNIME to it (“KNIME Interactive R Statistics Integration”) KNIME provides you with an ‘integrated’ R package that sits somewhere deep in the KNIME folders (“KNIME R Statistics Integration (Windows Binaries)”) I would advise to use the first option. So first to proper install R (and maybe RStudio to have an easier handling) and then point KNIME to it. There are further R integrations but t…

Once you have R up and running you will need **[RServe](https://www.rforge.net/Rserve/)** so that KNIME nodes can communicate with it. Again there are two flavours of nodes one is the [R environment managed by KNIME](https://nodepit.com/iu/org.knime.r) itself and then there is [R Scripting from the community](https://nodepit.com/category/community/r). The difference in using that is that the KNIME-managed one would just call RServe by itself while the R community nodes need RServe to be manually started from within R and the [RServe needs to be up and running](https://forum.knime.com/t/r-source-community-node-connection-error/13087/2) while using the nodes - that can be confusing, so maybe you stick with KNIME’s own nodes for now.

**About the RServe library itself …**

There have been some [problems](https://forum.knime.com/t/r-problems-on-macos-high-sierra-since-r-version-3-5/10935) with that and it is highly recommended you use the latest version of it which ist 1.8.6 as of now (Jan 2019).

In theory this should be as easy as running [this line in your R](https://forum.knime.com/t/r-problems-on-macos-high-sierra-since-r-version-3-5/10935/11) or RStudio.

`install.packages('Rserve',,"http://rforge.net/",type="source")`

or if you have the file in a local folder something like:

`install.packages('~/Downloads/Rserve_1.8-6.tar', repos = NULL, type="source")`

If that is not working you can try to install it manually by downloading the package - or trying to compile it yourself as we have discussed here:

> [@Issue with KNIME R version](https://forum.knime.com/t/issue-with-knime-r-version/12562/10):
>
> I mean the up to three KNIME extensions about R as mentioned before. I would deinstall them an install them again. Maybe first only using the “R Scripting extension” From my experience the most important thing is to update RServe to the latest version (1.8-6). You will have to compile the package yourself (depending on your platform) since there is no binary version ready for download (yet). [http://www.rforge.net/Rserve/files/](http://www.rforge.net/Rserve/files/) Download the .tar file and use it to install …

I also have an entry about being able to compile packages on Mac:

> [@KNIME : R evaluation failed.](https://forum.knime.com/t/knime-r-evaluation-failed/12560/13):
>
> And another thing. If you have to use the newest version of RServe you will have to compile the package. On MacOS you will need the packages mentioned on the relevant R website: [https://cran.r-project.org/bin/macosx/](https://cran.r-project.org/bin/macosx/) On a windows system you will have to compile the package with the help of RTools [https://cran.r-project.org/bin/windows/base/rw-FAQ.html#Can-I-install-packages-into-libraries-in-this-version\_003f](https://cran.r-project.org/bin/windows/base/rw-FAQ.html#Can-I-install-packages-into-libraries-in-this-version_003f) I recently noted that at least when compiling the RServe package Rtools does not li…

Compiling the Rserve package on [MacOS seems to be particularly tricky](https://forum.knime.com/t/errno8/13567/14) and seems to depend very much on the exact version of MacOS you use. Several steps have helped in the past.

- install R on MacOS ([R for macOS](https://cran.r-project.org/bin/macosx/))
- install RStudio ([RStudio IDE User Guide – RStudio User Guide](https://www.rstudio.com/products/rstudio/download/))
- install **XQuartz** ([https://www.xquartz.org](https://www.xquartz.org)) - not 100% sure if you need it for everything
- install **Clang 6.0.0** for OS X 10.11 and higher, ([R for macOS - Development Tools and Libraries](https://cran.r-project.org/bin/macosx/tools/))
- install **GNU Fortran 6.1** for OS X 10.11 and higher ([R for macOS - Development Tools and Libraries](https://cran.r-project.org/bin/macosx/tools/))
- run this installer if the compilation still does not work (cf. [this discussion](https://forum.knime.com/t/errno8/13567/14))  
`sudo installer -pkg \ /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg \ -target /`
- check out these hints for your specific version of MacOS ([R Installation and Administration](https://cran.r-project.org/doc/manuals/R-admin.html#macOS))

And please be aware that these hints might not work on every system or under any circumstances and as I have experienced these settings tend to change a lot, so please be patient and keep working on setting this up.

Being able to compile R libraries can also come in handy if you want to stay on top of the latest developments or you have some academic packages that are not hosted in a binary form on some server. Of course using new libraries can also bring some challenges with stability and bugs - like it is with advanced (free) software.

Yes there is some work to do but you will be better off once you have invested the effort. Hope you enjoy KNIME and R and if you have questions there is always the KNIME forum and the good people from KNIME there to help.

* * *

Since we are at it I want to share some more quirks about R that I have come across over the months. They may or may not be relevant for your problems.

1. On windows [RTools for compiling packages seem not to like very long and complex paths](https://forum.knime.com/t/knime-r-evaluation-failed/12560/13). So stick to something like c:\rtools instead of something fancy.

2. When installing new packages I have encountered problems with timezone. I could solve them by [explicitly giving a timezone](https://forum.knime.com/t/problem-with-r-snippet/12117/7) cf. this [entry](https://www.r-bloggers.com/doing-away-with-%E2%80%9Cunknown-timezone%E2%80%9D-warnings/).

3. Especially on Windows RServe seems to be picky if other instances of it are running parallel. So if you for example have a windows server and several people do use the same installation of R you might run into problems (I think there is a mention of that somewhere on the Rserve page). You might try for everyone to use their separate installations or different ports. Also you would want [not to start too many instances of R at the same time](https://forum.knime.com/t/problem-with-r-snippet/12117/9).

4. For further problems with compilation of Rserve please see this entry about [command line compilation with Rtools on Windows](https://forum.knime.com/t/r-nodes-hang/13362/3)

---

<div class="post-metadata">

**Author:** ![ScottF](https://forum-cdn.knime.com/user_avatar/forum.knime.com/scottf/32/61316_2.png) [@ScottF](https://forum.knime.com/u/ScottF)\
**Post date:** [February 4, 2019, 4:39pm UTC](https://forum.knime.com/t/install-r-alongside-knime-on-windows-and-macos/13287/2 "2019-02-04T16:39:01Z")

</div>

Thanks for this compilation! Very useful.

---

<div class="post-metadata">

**Author:** ![mattflor](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mattflor/32/251_2.png) [@mattflor](https://forum.knime.com/u/mattflor)\
**Post date:** [September 24, 2019, 6:04am UTC](https://forum.knime.com/t/install-r-alongside-knime-on-windows-and-macos/13287/3 "2019-09-24T06:04:25Z")

</div>

Thanks for the write-up! As a short addition, on my Windows 7 (64bit) system, compilation of the Rserve package for R 3.6.1 (64bit) always failed until I called it like this:  
`install.packages("Rserve",, "http://rforge.net/", type = "source", INSTALL_opts = "--no-multiarch"))`

---

<div class="post-metadata">

**Author:** ![Mark\_Ortmann](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/m/bc79bd/32.png) [@Mark\_Ortmann](https://forum.knime.com/u/Mark_Ortmann)\
**Post date:** [May 12, 2020, 9:27am UTC](https://forum.knime.com/t/install-r-alongside-knime-on-windows-and-macos/13287/4 "2020-05-12T09:27:23Z")

</div>

A comprehensive installation guide can be found here.

[R installation guide](https://docs.knime.com/2019-12/r_installation_guide/index.html)

If you’re still experiencing problems please don’t hesitate to contact us!

Best  
Mark

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [May 12, 2020, 10:44am UTC](https://forum.knime.com/t/install-r-alongside-knime-on-windows-and-macos/13287/5 "2020-05-12T10:44:30Z")

</div>

The script works well for MacOS. I found two things I had to change/remember:

- make the script executable on Mac ([Definieren einer Datei als ausführbar in Terminal auf dem Mac - Apple Support (DE)](https://support.apple.com/de-de/guide/terminal/apdd100908f-06b3-4e63-8a87-32e71241bab4/2.10/mac/10.15) | [Make a file executable in Terminal on Mac – Apple Support (UK)](https://support.apple.com/en-gb/guide/terminal/apdd100908f-06b3-4e63-8a87-32e71241bab4/2.10/mac/10.15))
- change the version number in the [script](https://bitbucket.org/KNIME/knime-r/src/master/org.knime.r/scripts/) to R 4.0.0

> R\_VERSION=4.0.0

On Windows you would have to install a new version of RTools in oder to get R 4.0 up and running

> **[RTools: Toolchains for building R and R packages from source on Windows](https://cran.r-project.org/bin/windows/Rtools/)**

* * *

Edit: [KNIME and R — installation across operating systems — some remarks | by Markus Lauber | Low Code for Data Science | Medium](https://medium.com/low-code-for-advanced-data-science/knime-and-r-installation-across-operating-systems-some-remarks-6494a2a498cc)

---

<div class="post-metadata">

**Author:** ![Ryon](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/r/e47774/32.png) [@Ryon](https://forum.knime.com/u/Ryon)\
**Post date:** [July 17, 2020, 12:43am UTC](https://forum.knime.com/t/install-r-alongside-knime-on-windows-and-macos/13287/6 "2020-07-17T00:43:11Z")

</div>

This post made my life so much better. Thank you so much for taking the time to write this out and share.

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [September 16, 2020, 6:13am UTC](https://forum.knime.com/t/install-r-alongside-knime-on-windows-and-macos/13287/7 "2020-09-16T06:13:43Z")

</div>

This article from 2019 tried to bring together all the information I had about installing and using R with KNIME on Windows and MacOS. Since then there have been some developments so I moved to the hub and wrote a hopefully useful guide - taking into account things like the new official guide by KNIME and the very helpful script to install homebrewe on MacOS in order to get RServe up and running.

I also tried to show some path how to approach problems with R and KNIME.

I will continue to update the hub entry to keep up with new developments:

> **[A meta collection and article about R and KNIME – mlauber71](https://hub.knime.com/mlauber71/spaces/Public/latest/_r_installation_on_knime_collection)**
>
> A meta collection and article about R and KNIME R gives you the power to do a lot of great things combined with KNIME but to get R and KNIME together up and ru…

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 23, 2023, 8:32pm UTC](https://forum.knime.com/t/install-r-alongside-knime-on-windows-and-macos/13287/8 "2023-06-23T20:32:22Z")

</div>


