Alexandr Malusek
2010-Oct-19 10:48 UTC
[R] Lattice: type="p" stopped working in panel.average
Hi, The behavior of panel.average has changed. In March 2010, I plotted the attached r_plotViolinOfAnnualE_old.eps. (I don't know the version of R). Today, I plotted the attached r_plotViolinOfAnnualE_new.eps using R version 2.12.0 (2010-10-15). Both figures were produced via the same script: ... plot <- bwplot(year ~ Eann, data=df, horizontal = T, xlab = "E / mSv", ylab = "year", box.ratio = 1.5, panel=function(...) { panel.grid(h=0, v=-1) panel.average(fun=max, type="p", pch=3, col="black", ...) panel.violin(adjust=0.3, kernel="gaussian", ...) panel.average(fun=min, type="p", pch=3, col="black", ...) panel.average(fun=mean, type="p", pch=20, col="black", ...) panel.average(fun=median, type="p", pch=0, col="black", ...) } ) ... The old version of R plotted points as defined by type="p", the new version plotted lines. I don't know whether it is a bug or a new feature. Anyway, is there an easy way of getting the old result with the new version of R? Regards, Alexandr -------------- next part -------------- A non-text attachment was scrubbed... Name: r_plotViolinOfAnnualE_old.eps Type: application/postscript Size: 22048 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20101019/4dfafa23/attachment.eps> -------------- next part -------------- A non-text attachment was scrubbed... Name: r_plotViolinOfAnnualE_new.eps Type: application/postscript Size: 20832 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20101019/4dfafa23/attachment-0001.eps>
Deepayan Sarkar
2010-Oct-19 11:52 UTC
[R] Lattice: type="p" stopped working in panel.average
On Tue, Oct 19, 2010 at 4:18 PM, Alexandr Malusek <alexandr.malusek at gmail.com> wrote:> Hi, > > The behavior of panel.average has changed. ?In March 2010, I plotted > the attached r_plotViolinOfAnnualE_old.eps. (I don't know the version > of R). Today, I plotted the attached r_plotViolinOfAnnualE_new.eps > using R version 2.12.0 (2010-10-15). Both figures were produced via > the same script: > > ... > plot <- bwplot(year ~ Eann, data=df, horizontal = T, > ?xlab = "E / mSv", > ?ylab = "year", > ?box.ratio = 1.5, > ?panel=function(...) { > ? ?panel.grid(h=0, v=-1) > ? ?panel.average(fun=max, type="p", pch=3, col="black", ...) > ? ?panel.violin(adjust=0.3, kernel="gaussian", ...) > ? ?panel.average(fun=min, type="p", pch=3, col="black", ...) > ? ?panel.average(fun=mean, type="p", pch=20, col="black", ...) > ? ?panel.average(fun=median, type="p", pch=0, col="black", ...) > ?} > ) > ... > > The old version of R plotted points as defined by type="p", the new > version plotted lines. I don't know whether it is a bug or a new > feature. Anyway, is there an easy way of getting the old result with > the new version of R?The change happened in Dec 2009, probably to prevent unintended capturing of 'type' (panel.average is an alias for panel.linejoin, which indicates that the original intention was to draw lines). In hindsight, this was probably not the best choice. However, you can get the same effect fairly easily with mypanel.average <- function(x, y, FUN = mean, ...) { panel.points(aggregate(as.numeric(y) ~ x, data = environment(), FUN = FUN), ...) } -Deepayan