Hello, there seems to be a bug in tapply or barplot in R 1.9.0 that was not in earlier versions. The following code creates two nice barplots in 1.7.0, but the first one is bad in 1.9.0: par(mfrow=3Dc(1,2)) x <- rep(1:10,10) y <- runif(100,1,100) z <- tapply(y,x,mean) barplot(z) barplot(as.numeric(z)) although is.numeric(z) returns TRUE! Best regards, Vidar Hjellvik Institute of Marine Research P.O.Box 1870 Nordnes N-5817 Bergen phone: +47 55 23 86 62 email: vidarh@imr.no
But not in R 1.9.1 beta, due for release next Monday. This has been reported quite a few times already -- see the R-help archives and PR#6676/7/8 and PR#6894, for example. Note that the plots in 1.9.1 beta are deliberately different from 1.7.0. On Tue, 15 Jun 2004 Vidar.Hjellvik@imr.no wrote:> Hello, > > there seems to be a bug in tapply or barplot in R 1.9.0 that was not in > earlier versions.It's not a bug, rather a design change. That change has been revisited in 1.9.1.> The following code creates two nice barplots in 1.7.0, > but the first one is bad in 1.9.0: > > par(mfrow=c(1,2)) > x <- rep(1:10,10) > y <- runif(100,1,100) > z <- tapply(y,x,mean) > barplot(z) > barplot(as.numeric(z)) > > although is.numeric(z) returns TRUE!Yes, but z is a 1D array, and as.numeric makes it into a numeric *vector*. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Vidar.Hjellvik@imr.no writes:> Hello, > > there seems to be a bug in tapply or barplot in R 1.9.0 that was not in > earlier versions. The following code creates two nice barplots in 1.7.0, > but the first one is bad in 1.9.0: > > par(mfrow=3Dc(1,2)) > x <- rep(1:10,10) > y <- runif(100,1,100) > z <- tapply(y,x,mean) > barplot(z) > barplot(as.numeric(z))We know. Please check the relevant sources for previous reports, and, in particular at this stage, the current 1.9.1beta!> > although is.numeric(z) returns TRUE!That's irrelevant: as.numeric does more than convert to numeric. Try this for instance: m <- matrix(1:6,2) barplot(m) barplot(as.numeric(m)) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907