Re: [R] bwplot superpose panel.points from another dataframe
Thanks for your help Peter but the red marks on boxplot do not correspond to ex2 dataframe actually, it reproduce on each panel the same marks that is to say the 3 first lines of ex2 So this is not correct Christophe On Mon, Sep 27, 2010 at 6:18 PM, Peter Ehlers ehl...@ucalgary.ca wrote: On 2010-09-27 4:54, Christophe Bouffioux wrote: bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), pch = |, par.settings = list( plot.symbol = list(alpha = 1, col = transparent,cex = 1,pch = 20)), panel = function(x, y){ panel.bwplot(x, y) X- tapply(ex3$v1b, ex3[,c(1,2)], max) Y- seq(length(unique(ex3[,c(1,2)]))) panel.points(X, Y, pch = 17, col = red) }) Perhaps this is what you're trying to achieve: bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), panel = function(x, y){ panel.bwplot(x, y, pch=|) X - tapply(ex3$v1b, ex3[, 1:2], max) Y - seq(nrow(unique(ex3[, 1:2]))) panel.points(X, Y, pch = 17, col = red) }) (I didn't see any need for your par.settings.) I'm not crazy about the way you define X,Y. I think I would augment the data frame appropriately instead. -Peter Ehlers [[alternative HTML version deleted]] __ 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.
Re: [R] bwplot superpose panel.points from another dataframe
Hi: I did this in ggplot2, which seemed easier than the approach you tried in lattice's bwplot() - as far as I can tell, you want to plot the unique value of v1b as a red dot in each boxplot. To that end, ex - data.frame(v1 = log(abs(rt(180, 3)) + 1), v2 = rep(c(2007, 2006, 2005), 60), z = rep(c(a, b, c, d, e, f), e = 30)) # the individual to be marked ex2 - data.frame(v1b = log(abs(rt(18, 3)) + 1), v2 = rep(c(2007, 2006, 2005), 6), z = rep(c(a, b, c, d, e, f), e = 3)) ex3 - merge(ex, ex2, by=c(v2,z)) library(ggplot2) h - ggplot(ex3) h + geom_boxplot(aes(x = v2, y = v1)) + geom_point(aes(x = v2, y = v1b), shape = 17, colour = 'red', size = 3) + coord_flip() + facet_wrap( ~ z) + opts(panel.minor.grid = theme_blank()) + theme_bw() It has a different look from bwplot(), but it appears to me that the points are correctly located. HTH, Dennis On Tue, Sep 28, 2010 at 12:29 AM, Christophe Bouffioux christophe@gmail.com wrote: Thanks for your help Peter but the red marks on boxplot do not correspond to ex2 dataframe actually, it reproduce on each panel the same marks that is to say the 3 first lines of ex2 So this is not correct Christophe On Mon, Sep 27, 2010 at 6:18 PM, Peter Ehlers ehl...@ucalgary.ca wrote: On 2010-09-27 4:54, Christophe Bouffioux wrote: bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), pch = |, par.settings = list( plot.symbol = list(alpha = 1, col = transparent,cex = 1,pch = 20)), panel = function(x, y){ panel.bwplot(x, y) X- tapply(ex3$v1b, ex3[,c(1,2)], max) Y- seq(length(unique(ex3[,c(1,2)]))) panel.points(X, Y, pch = 17, col = red) }) Perhaps this is what you're trying to achieve: bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), panel = function(x, y){ panel.bwplot(x, y, pch=|) X - tapply(ex3$v1b, ex3[, 1:2], max) Y - seq(nrow(unique(ex3[, 1:2]))) panel.points(X, Y, pch = 17, col = red) }) (I didn't see any need for your par.settings.) I'm not crazy about the way you define X,Y. I think I would augment the data frame appropriately instead. -Peter Ehlers [[alternative HTML version deleted]] __ 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]] __ 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.
Re: [R] bwplot superpose panel.points from another dataframe
On Tue, Sep 28, 2010 at 12:59 PM, Christophe Bouffioux christophe@gmail.com wrote: Thanks for your help Peter but the red marks on boxplot do not correspond to ex2 dataframe actually, it reproduce on each panel the same marks that is to say the 3 first lines of ex2 So this is not correct You are probably looking for something like these: bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), X = ex3$v1b, pch = |, panel = function(x, y, ..., X, subscripts){ panel.bwplot(x, y, ..., subscripts = subscripts) X - X[subscripts] X - tapply(X, y, unique) Y - tapply(y, y, unique) panel.points(X, Y, pch = 17, col = red) }) bwplot(v2 ~ v1 | z, data = ex, layout=c(3,2), ext.data = ex2, pch = |, panel = function(x, y, ..., ext.data){ panel.bwplot(x, y, ...) i - which.packet() sub - subset(ext.data, as.numeric(z) == i) with(sub, panel.points(v1b, v2, pch = 17, col = red)) }) -Deepayan Christophe On Mon, Sep 27, 2010 at 6:18 PM, Peter Ehlers ehl...@ucalgary.ca wrote: On 2010-09-27 4:54, Christophe Bouffioux wrote: bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), pch = |, par.settings = list( plot.symbol = list(alpha = 1, col = transparent,cex = 1,pch = 20)), panel = function(x, y){ panel.bwplot(x, y) X- tapply(ex3$v1b, ex3[,c(1,2)], max) Y- seq(length(unique(ex3[,c(1,2)]))) panel.points(X, Y, pch = 17, col = red) }) Perhaps this is what you're trying to achieve: bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), panel = function(x, y){ panel.bwplot(x, y, pch=|) X - tapply(ex3$v1b, ex3[, 1:2], max) Y - seq(nrow(unique(ex3[, 1:2]))) panel.points(X, Y, pch = 17, col = red) }) (I didn't see any need for your par.settings.) I'm not crazy about the way you define X,Y. I think I would augment the data frame appropriately instead. -Peter Ehlers [[alternative HTML version deleted]] __ 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. __ 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.
Re: [R] bwplot superpose panel.points from another dataframe
BINGO we have the solution thanks a lot both, Deepayan and Dennis, for your help Christophe On Tue, Sep 28, 2010 at 2:10 PM, Deepayan Sarkar deepayan.sar...@gmail.comwrote: On Tue, Sep 28, 2010 at 12:59 PM, Christophe Bouffioux christophe@gmail.com wrote: Thanks for your help Peter but the red marks on boxplot do not correspond to ex2 dataframe actually, it reproduce on each panel the same marks that is to say the 3 first lines of ex2 So this is not correct You are probably looking for something like these: bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), X = ex3$v1b, pch = |, panel = function(x, y, ..., X, subscripts){ panel.bwplot(x, y, ..., subscripts = subscripts) X - X[subscripts] X - tapply(X, y, unique) Y - tapply(y, y, unique) panel.points(X, Y, pch = 17, col = red) }) bwplot(v2 ~ v1 | z, data = ex, layout=c(3,2), ext.data = ex2, pch = |, panel = function(x, y, ..., ext.data){ panel.bwplot(x, y, ...) i - which.packet() sub - subset(ext.data, as.numeric(z) == i) with(sub, panel.points(v1b, v2, pch = 17, col = red)) }) -Deepayan Christophe On Mon, Sep 27, 2010 at 6:18 PM, Peter Ehlers ehl...@ucalgary.ca wrote: On 2010-09-27 4:54, Christophe Bouffioux wrote: bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), pch = |, par.settings = list( plot.symbol = list(alpha = 1, col = transparent,cex = 1,pch = 20)), panel = function(x, y){ panel.bwplot(x, y) X- tapply(ex3$v1b, ex3[,c(1,2)], max) Y- seq(length(unique(ex3[,c(1,2)]))) panel.points(X, Y, pch = 17, col = red) }) Perhaps this is what you're trying to achieve: bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), panel = function(x, y){ panel.bwplot(x, y, pch=|) X - tapply(ex3$v1b, ex3[, 1:2], max) Y - seq(nrow(unique(ex3[, 1:2]))) panel.points(X, Y, pch = 17, col = red) }) (I didn't see any need for your par.settings.) I'm not crazy about the way you define X,Y. I think I would augment the data frame appropriately instead. -Peter Ehlers [[alternative HTML version deleted]] __ 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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ 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.
Re: [R] bwplot superpose panel.points from another dataframe
On 2010-09-27 4:54, Christophe Bouffioux wrote: bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), pch = |, par.settings = list( plot.symbol = list(alpha = 1, col = transparent,cex = 1,pch = 20)), panel = function(x, y){ panel.bwplot(x, y) X- tapply(ex3$v1b, ex3[,c(1,2)], max) Y- seq(length(unique(ex3[,c(1,2)]))) panel.points(X, Y, pch = 17, col = red) }) Perhaps this is what you're trying to achieve: bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), panel = function(x, y){ panel.bwplot(x, y, pch=|) X - tapply(ex3$v1b, ex3[, 1:2], max) Y - seq(nrow(unique(ex3[, 1:2]))) panel.points(X, Y, pch = 17, col = red) }) (I didn't see any need for your par.settings.) I'm not crazy about the way you define X,Y. I think I would augment the data frame appropriately instead. -Peter Ehlers __ 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.