[R] Strange behavior in Lattice when superimposing

Deepayan Sarkar deepayan at stat.wisc.edu
Tue Apr 19 16:47:51 CEST 2005


On Tuesday 19 April 2005 02:19, Adam Lyon wrote:
> Hi,
>
> I am trying to do a simple superimposing of two density plots and am
> seeing strange behavior (I haven't seen this reported elsewhere).
> This little snipit will make it apparent...
>
> a = rnorm(10)
> b = rnorm(100, mean=-2, sd=0.5)
> densityplot( ~ a + b)

I'm not sure if this is explicitly documented anywhere (perhaps not), 
but the variables in the formula have to have the same length. What you 
should really do is 

densityplot(~ c(a, b), groups = rep(c('a', 'b'), c(10, 100))

Your usage should have triggered an error; I'll see if I can make that 
happen.

Deepayan




More information about the R-help mailing list