Product: TIBCO Spotfire®
Data function's TERR script to send commands to open-source R fails with error 'could not find function "REvaluate"'
A Spotfire data function's TIBCO Enterprise Runtime for R (TERR) script that sends commands to open-source R fails with error 'could not find function "REvaluate"'.
The REvaluate() function can be used to send data and commands out to an open-source R instance that has been downloaded from the open-source R community's CRAN repository (https://cran.r-project.org/) and installed on the same machine.
The REvaluate() function is part of TERR's optional built-in "RinR" package.
The "RinR" package does not need to be installed in TERR, but it does need to be loaded into the current TERR session's search() path before the script makes any calls to REvaluate().
The following TERR script demonstrates this, using a call to library(RinR) at the top of the script. Inside the call to REvaluate(), it installs, loads and uses the user-contributed "jsonlite" and "curl" packages from the open-source R community's CRAN repository.
## Load TERR's optional built-in "RinR" package ##
## Set the option that will tell REvaluate() where to find open-source R: ##
FullPathToOpenSourceR <- "C:/Program Files/R/R-3.4.1/bin/R.exe"
options( RinR_R_FULL_PATH = FullPathToOpenSourceR )
## Check to see if the specified path to R exists ##
if( ! file.exists(FullPathToOpenSourceR) )
stop( "A path to open source R must be provided before calling REvaluate() or RGraph()." )
## Define a valid json URL ##
jsonURL <- "https://feeds.citibikenyc.com/stations/stations.json"
## Run the call to REvaluate() ##
OutputFromR <- REvaluate(
data = list( jsonURL = jsonURL),
for( CranPackageName in c("jsonlite", "curl") )
if( ! CranPackageName %in% rownames( installed.packages() ) )
install.packages( CranPackageName, repos = "https://cloud.r-project.org" )
library( CranPackageName, character.only = TRUE )
data_R <- data.frame(
fromJSON( jsonURL ),
stringsAsFactors = FALSE)
## simplify the output data frame's column names ##
colnames(OutputFromR) <- gsub( "stationBeanList.", "", colnames(OutputFromR) )
The following knowledge base articles also provide examples and information on using the REvaluate() and RGraph() functions from TERR's optional built-in "RinR" package: