Skip to content
Back to formatted view

Raw Message

Message-ID: <AANLkTinPSQikEaZAQnAVt+Xim12dS3OkU7fPMOCiLU4P@mail.gmail.com>
Date: 2010-12-09T19:18:11Z
From: Deepayan Sarkar
Subject: Condional Density Plot from different data
In-Reply-To: <C0772C7568B5374481D2F8A880E9BBDF06A692D9CE@DC1EX07CMS.air.org>

On Thu, Dec 9, 2010 at 10:11 AM, Doran, Harold <HDoran at air.org> wrote:
> Perhaps I found a solution as:
>
> datA$type <- gl(1, nrow(datA), label = 'PopA')
> datB$type <- gl(1, nrow(datB), label = 'PopB')
> dat <- rbind(datA, datB)

Or, slightly shorter

dat <- make.groups(datA, datB)
densityplot(~scores|condition, groups = which, dat)

> [...]

>> library(lattice)
>> densityplot(~datA$scores + datB$scores|datA$condition)

The problem here is that datA$scores and datB$scores don't have the
same length. This requirement is implicit in the description of the
extended formula interface:

          'y1 + y2 ~ x | a * b' [...] would be taken to mean that the
user wants to plot
          both 'y1 ~ x | a * b' and 'y2 ~ x | a * b' [...] superposed
in each panel.

and the latter formulae would make sense only if x, a, b, and y1 (and
y2) have the same length.

-Deepayan