Michael Stob
2013-Feb-13 13:38 UTC
[R] densityplot(~x+y) for vectors of different lengths does what?
densityplot(~x+y) does what I expect it to do if x and y have equal length. I know how to get what I want if x and y have different lengths. But what is this actually doing if x and y have different lengths? The relevant example is x=rnorm(10) y=rnorm(50,1) densityplot(~x+y)
ilai
2013-Feb-13 19:02 UTC
[R] densityplot(~x+y) for vectors of different lengths does what?
Hmmm... is this a (unknown or even a) bug ? Not sure this is what OP was getting at and I haven't gone through the lattice docs to see if this is mentioned, but, with unequal sizes the extended formula is not producing what one (or at least I) might expect: require(latticeExtra) set.seed(4321) ; x <- rnorm(20) ; y <- rnorm(10 , 50) c(dsp <- densityplot( ~ x + y) , densityplot( ~ data , groups = which , make.groups(x, y) ) ) # because all.equal(dsp$panel.args[[1]]$x, c(x, y) ) # but regroups ignoring original lengths summary(dsp$panel.args.common$groups) An obvious BTW: problem persists using n={19,11} or n = {20,11} sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-pc-linux-gnu (64-bit) attached base packages: [1] grDevices utils datasets stats graphics methods base other attached packages: [1] nlme_3.1-104 latticeExtra_0.6-24 RColorBrewer_1.0-5 [4] lattice_0.20-10 On Wed, Feb 13, 2013 at 6:38 AM, Michael Stob <stob@calvin.edu> wrote:> densityplot(~x+y) does what I expect it to do if x and y have equal > length. I know how to get what I want if x and y have different lengths. > But what is this actually doing if x and y have different lengths? The > relevant example is > > x=rnorm(10) > y=rnorm(50,1) > densityplot(~x+y) > > > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >[[alternative HTML version deleted]]
Possibly Parallel Threads
- Problems drawing a colored 'rug' in the Lattice 'densityplot'
- How to generate a figure using par( ) with some densityplot( )'s
- small issue with densityplot
- awkward behavior with densityplot function
- How to adjust y-axis when using panel.densityplot within histogram function