Using smooth spline in stat scale in ggplot2…

Using smooth.spline in stat_scale in ggplot2

smooth.spline2 <- function(formula, data, ...) { 
  mat <- model.frame(formula, data) 
  smooth.spline(mat[, 2], mat[, 1]) 
} 

predictdf.smooth.spline <- function(model, xseq, se, level) { 
  pred <- predict(model, xseq) 
  data.frame(x = xseq, y = pred$y) 
} 

qplot(mpg, wt, data = mtcars) + geom_smooth(method = "smooth.spline2", se= F)

From: http://groups.google.com/group/ggplot2/browse_thread/thread/149dfa0891fe383a

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *