Product: TIBCO Spotfire®
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...'
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"':
#----
require(Rfast)
dfB <- Sort(dfA$scores)
#----
(B) The following script will make the data function return "Error in library(Rfast) : there is no package called 'Rfast'":
#----
library(Rfast)
dfB <- Sort(dfA$scores)
#----
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.
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():
#----
library(Rfast)
dfB <- Sort(dfA$scores)
#----
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:
?require
Comments
0 comments
Article is closed for comments.