I have been trying for a few days to get Spotfire to create a table of charts , which i can then plot on a map chart using lables. I have the following script which works well for the base R hist() plot, but when i change this to ggplot to create the charts i need i get the following error
Error in REvaluate(bquote({
.(Rfunction)(.(file), width = .(width : Error : data
must be a data frame, or other object coercible by fortify()
, not a numeric vector
What do i need to do to get ggplot working in this script ( if it can?) it looks like the split function is creating data not usable by ggplot?
library( RinR )
irisFrameSplit <- split( iris$Sepal.Width, iris$Species )
irisGraphsList <-
lapply(
X = irisFrameSplit,
FUN = function(X)
RGraph(
data = list( X = X ),
height = 680,
width = 680,
package = 'ggplot2',
expr =
{
hist(X, col = 'red')
#ggplot(X, aes(x=Sepal.Width)) + geom_histogram()
} ) )
irisGraphsDF <-
data.frame(
Species = names( irisGraphsList ),
PlotImage = seq( along = irisGraphsList ),
stringsAsFactors = FALSE )
irisGraphsDF[["PlotImage"]] <- irisGraphsList
many thanks for any help
just need to add a print statement into the script, use ggplot (so must use print() to make the plot). Since xyplot() includes data argument, RGraph does not try to send over the vectors named in its formula argument.
print(
ggplot(X, aes(x = Petal.Width, )) + geom_histogram())