If a TERR or R package is not installed and a data function's script loads it using 'require()', the data function can fail with a 'could not find function...' error instead of 'there is no package called...'
book
Article ID: KB0081240
calendar_today
Updated On:
Products
Versions
Spotfire Analyst
All supported versions
Spotfire Web Player
All supported versions
Spotfire Enterprise Runtime for R
All supported versions
Description
If a TIBCO Enterprise Runtime for R (TERR) or open-source R package is not installed and a Spotfire data function's TERR or R script loads it using 'require()', the data function can fail with a 'could not find function...' error instead of 'there is no package called...'
Example:
For example, a data function's script might use the Sort() function from the user-contributed CRAN package named "Rfast". (Note that TERR and R are case sensitive. This means that the package's Sort() function is distinct from the built-in sort() function.)
If the "Rfast" package has not been installed in the TERR or R instance that is running the script,
(A) The following script will make the data function return 'Error: could not find function "Sort"':
When the package of interest has not been installed, library() throws a fatal error message that the data function will return to Spotfire as an Alert in Spotfire, but require() throws a warning, which will not be shown in the Alert if a fatal error is generated later in the script.
This means that the 'could not find function "Sort"' error message, which is generated by the second line in the script, is the only message that appears in the Alert.
Issue/Introduction
If a TERR or R package is not installed and a data function's script loads it using 'require()', the data function can fail with a 'could not find function...' error instead of 'there is no package called...'
Environment
All supported environment
Resolution
In a Spotfire data function's TERR or R script, using a call to library() will provide a more informative error message than using require():
In a TERR Console session, the following command will open a web browser tab with the help topic that covers both the library() function and the require() function: