[R] trellis help

Deepayan Sarkar deepayan.sarkar at gmail.com
Mon Mar 20 02:57:41 CET 2006


On 3/19/06, Alexander Nervedi <alexnerdy at hotmail.com> wrote:
> apoplogies for the repeat post - i just realized i forgot to change the
> subject line
>
>
> I dont as yet fully understand how trellis works. Advice would be much
> appreciated.
>
> I have a factor variable (2 levels) and a continuous variable and I am able
> to plot a histogram of the frequencies of the continuous variable for each
> level of the factor variable using :
>
> histogram( ~ e.ps | vdc, data = est.prop.score,
>                                     xlab = "Propensity Score", type =
> "density",
>                                              panel = function(x, ...) {
>                                               panel.histogram(x, ...)
>                                   panel.mathdensity(dmath = dnorm, col =
> "black",
>                                         args = list(mean=mean(x),sd=sd(x)))
>
> The two distributions overlap over an area and I would like to draw vertical
> lines to demark the lower tail of the distribution which has a higher
> median, and the right tail of the distribution with lower  median.

You can compute these quantities beforehand and add them using
panel.abline (inside your panel function). It's not entirely
impossible to do it in a single histogram call, but that won't look
pretty.

Deepayan




More information about the R-help mailing list