Reputation: 141
I would like to use ggplot.Predict (from the rms
package) in a function to produce graphs automatically:
library(rms)
ddist <- datadist(iris); options(datadist="ddist")
mod <- ols(Sepal.Length ~ Petal.Length, data=iris)
p.plot <- function(pred, ttl) {
ggplot(pred,
addlayer=labs(title=ttl))
}
plot.title <- "Sepal length"
p.plot(Predict(mod), plot.title)
This results in an "Error in labs(title = ttl) : object 'ttl' not found" The following however works without problems.
ggplot(Predict(mod), addlayer=labs(title=plot.title))
Upvotes: 0
Views: 168