Rserve is a TCP/IP server that allows users to run R scripts directly from WebFOCUS or the Reporting Server without the need to initialize R or link to an R library.
The adapter is available on UNIX, Linux, and Windows. On UNIX and Linux, Rserve allows parallel sessions and, therefore, the environment supports multiple users. On Windows, Rserve does not support parallel connections. Multiple sessions are shared, so the environment supports a single user at a time.
The installation of R and Rserve, and the creation of the model are done without server or WebFOCUS involvement, and are prerequisites for configuring and using the Adapter for Rserve.
Prerequisites
R Script Features
The R script that will read and run the model must conform to the following rules:
args <- commandArgs(trailingOnly=TRUE)
input_file <- file.path(args[1]) output_file <- file.path(args[2])
colnames(results) <- c('Price') write.csv(results, file=output_file, row.names=FALSE)
For a complete example, see Sample Session: Creating a Synonym for an R Script and Running the Script.
Server and WebFOCUS Steps
Once you have a model and the R script that runs it, you need a sample .csv file that contains a few rows of data for the independent variables used in the model. This file will be used to determine the data types and lengths of the independent variables when you create a synonym for the model.
Later, when you run the model from WebFOCUS, you will need a data file to run against that will provide values for the input variables to be passed to the RSERVE function. The function will return the result of running the model as output.
Therefore, the following steps must be completed in the server Web Console and WebFOCUS.
The following diagram summarizes the process of preparing the model, named my_model, to be called in a WebFOCUS procedure.
The following diagram summarizes the process of calling the model named my_model in a WebFOCUS procedure (against a data source supported by R).
WebFOCUS | |
Feedback |