[R] rlm results on trellis plot

hadley wickham h.wickham at gmail.com
Fri Jun 8 16:25:17 CEST 2007


On 6/7/07, Alan S Barnett <asb at mail.nih.gov> wrote:
> How do I add to a trellis plot the best fit line from a robust fit? I
> can use panel.lm to add a least squares fit, but there is no panel.rlm
> function.

It's not trellis, but it's really easy to do this with ggplot2:

install.packages("ggplot2", dep=T)
library(ggplot2)

p <- qplot(x, y, data=diamonds)
p + geom_smooth(method="lm")
p + geom_smooth(method="rlm")
p + geom_smooth(method="lm", formula="y ~ poly(x,3)")

see http://had.co.nz/ggplot2/stat_smooth.html for more examples.

Hadley



More information about the R-help mailing list