When developing a Spotfire data function written in R for use with the R or TIBCO Enterprise Runtime for R engine, it is useful to start development by simply saving data so it can be loaded into an interactive R or TIBCO Enterprise Runtime for R session in RStudio (or other IDE).
TERR and Spotfire data conversions behave differently, so they can result in unexpected differences in data. To make sure you are not surprised when you test your data functions in TERR, and then run them in Spotfire, follow the steps to ensure the same data format in this Tips and Tricks article.
You can use RinR package to call Open Source R graphics libraries such as ggplot and create a visualization to display in Spotfire. This article outlines how to do that.