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 ##
library(RinR)
## 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),
expr =
{
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)
data_R
} )
## 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:
https://support.tibco.com/s/article/How-to-use-the-data-and-expr-arguments-in-the-REvaluate-function-from-TERR-s-RinR-package-to-send-data-and-expressions-out-to-an-open-source-R-session
https://support.tibco.com/s/article/TERR-TSSS-or-a-Spotfire-data-function-returns-Error-in-REvaluate-there-is-no-package-called
https://support.tibco.com/s/article/Error-in-REvaluator-when-running-REvaluate-or-RGraph-in-the-RinR-package
https://support.tibco.com/s/article/How-to-create-a-graph-using-TERR-by-calling-open-source-R-functions-via-the-RinR-package
https://support.tibco.com/s/article/Example-TERR-RinR-RGraph-data-function-that-returns-a-column-of-R-qqnorm-graphs-in-a-Spotfire-data-table
Comments
0 comments
Article is closed for comments.