Skip to content
Prev 275149 / 398506 Next

lattice::xyplot/ggplot2: plotting weighted data frames with lmline and smooth

Hi Michael:

The necessary argument to geom_smooth() is weight, not weights (my
fault, sorry), so try this instead:

ggplot(PearsonLee, aes(x = parent, y = child)) +
   geom_point(size = 1.5, position = position_jitter(width = 0.2)) +
   geom_smooth(method = lm, aes(weight = frequency,
               colour = 'Linear'), se = FALSE, size = 1.5) +
   geom_smooth(aes(weight = frequency,
               colour = 'Loess'), se = FALSE, size = 1.5) +
   facet_grid(chl ~ par) +
   scale_colour_manual(breaks = c('Linear', 'Loess'),
                       values = c('green', 'red')) +
   opts(legend.position = c(0.14, 0.885),
        legend.background = theme_rect(fill = 'white'))

Dennis
On Fri, Oct 21, 2011 at 11:57 AM, Michael Friendly <friendly at yorku.ca> wrote: