[R] Condional Density Plot from different data
Deepayan Sarkar
deepayan.sarkar at gmail.com
Thu Dec 9 20:18:11 CET 2010
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
More information about the R-help
mailing list