A set of nodes which allows you to use the statistical computing language R in node RED.
Add @inNETMonitoring:registry=https://npm.pkg.github.com/
to your .npmrc file.
Execute npm install @inNETMonitoring/node-red-contrib-r-nodes
inside your
Node RED root directory.
Install R on the computer you'd like to use as the R server. It can be downloaded on the R Project Website.
After installation of R install all requirements/libraries required for the remote code execution. Start R and execute the following commands:
install.packages('RJSONIO')
install.packages('Rserve')
Start the R interpreter and run the following commands to start Rserve
.
library(Rserve)
Rserve()
This is a configuration node to set up a connection to a host running R and RServe.
The R Script node provides the possibility to write R code directly
in node RED. When the node receives a msg
its payload
is copied to the R server and
your script is executed afterwards. You can manipulate the msg.payload
property
with default R code. After the code is successfully executed, the payload
property
is copied back to msg
and is emitted at the nodes output.
Here is some sample code on how to access the msg
object in R:
data <- payload$data;
payload$mean <- mean(data);
payload$median <- median(data);
Caution:
The variable type is not converted by this node. You have to make sure, the
data types of the members you want to access or manipulate are represented by
the correct datatype (e.g. array of floats).
A working example flow can be found on the nodeRED flow repository.