[R] Weighted box or violin plots in Lattice?

Deepayan Sarkar deepayan.sarkar at gmail.com
Sun May 8 20:35:10 CEST 2011


On Sat, May 7, 2011 at 1:55 AM, Raphael Mazor <raphaelm at sccwrp.org> wrote:
> Is it possible to create weighted boxplots or violin plots in lattice?
>
> It seems that you can specify weights for panel.histogram() and
> panel.densityplot(), but not for panel.bwplot or panel.violin().

Not for panel.histogram() either.

It's not immediately obvious how you would get weighted boxplots. For
weighted violin plots, it should not be too difficult to write your
own panel function generalizing panel.violin(); just pass in 'weights'
and 'subscripts', and get the per-panel weights inside the panel
function as weights[subscripts] (as in panel.densityplot).

The only difference is that densityplot() implements non-standard
evaluation for 'weights', which bwplot() does not, so you have to
specify 'weights' explicitly.

-Deepayan



More information about the R-help mailing list