The following TERR code will create a graph using open-source R:
library( RinR )
library( Sdatasets )
# If running from a Spotfire data function, you will need to
# set the path to your local open-source R installation.
# For example:
# pushPATH( "C:\\Program Files\\R\\R-3.3.2\\bin" )
graph <- RGraph(
expr =
{
par( mfrow = c(3, 2) )
plot(
lm( fuel.frame$Mileage ~ fuel.frame$Weight ),
which = 1:6,
ask = F )
},
data = list( fuel.frame = fuel.frame ),
display = FALSE
)
You can add code to save the graph to file (i.e. png, jpg, etc...), as in this example:
library( RinR )
library( Sdatasets )
if( ! dir.exists( "C:\\MyGraphicsTestDir" ) )
{
dir.create( "C:\\MyGraphicsTestDir" )
}
# If running from a Spotfire data function, you will need to
# set the path to your local open-source R installation,
# for example:
# pushPATH( "C:\\Program Files\\R\\R-3.3.2\\bin" )
graph <- RGraph(
expr =
{
png( file = "C:\\MyGraphicsTestDir\\myplot.png", bg = "transparent")
par( mfrow = c(3, 2) )
plot(
lm( fuel.frame$Mileage ~ fuel.frame$Weight ),
which = 1:6,
ask = F
)
dev.off()
},
data = list( fuel.frame = fuel.frame ),
display = FALSE
)
Or you can return the graph to Spotfire as a binary object, for display in Spotfire when calling the following code from a Spotfire data function:
library( RinR )
library( Sdatasets )
# Set the path to your local open-source R installation:
pushPATH( "C:\\Program Files\\R\\R-3.3.2\\bin" )
graph <- RGraph(
expr =
{
par( mfrow = c(3, 2) )
plot(
lm( fuel.frame$Mileage ~ fuel.frame$Weight ),
which = 1:6,
ask = F )
},
data = list( fuel.frame = fuel.frame ),
display = FALSE
)
graph <- as.raw( graph )
To see a full step-by-step example, please refer to the Spotfire Knowledge Base article #000020714 (https://support.tibco.com/s/article/Tibco-KnowledgeArticle-Article-43727).