[R] tapply() and barplot() help files for 1.8.1

Duncan Murdoch dmurdoch at pair.com
Thu Apr 15 18:45:24 CEST 2004


On Thu, 15 Apr 2004 18:10:27 +0200, Martin Maechler
<maechler at stat.math.ethz.ch> wrote :

>>>>>> "David" == David Whiting <david.whiting at ncl.ac.uk>
>>>>>>     on 15 Apr 2004 11:42:18 +0000 writes:
>
>    David> Hi,
>
>    David> I've just upgraded to 1.9.0 and one of my Sweave
>    David> files that produces a number of barplots in a
>    David> standard manner now produces them in a different way.
>    David> I have made a couple of small changes to my code to
>    David> get the back the output I was getting before
>    David> upgrading and now (mostly out of curiosity) would
>    David> like to understand what has changed.
>
>and I like to help you.
>As I keep installed `(almost) all released versions of R ever
>installed on our machines'
>I can easily run 1.8.1 (or 1.4.x or 1.0.x ...) for you.
>
>The only difference
> between the help page help(tapply)
>is an extra   "require(stats)" statement at the beginning of the
>`Examples' section in 1.9.0.
>
>and the only change to  tapply() is 
>    group <- rep.int(one, nx)#- to contain the splitting vector
>instead of
>    group <- rep    (one, nx)#- to contain the splitting vector
>
>which hardly should have adverse results.
>
>In barplot, there's the new 'offset' option  --- not in NEWS (!!!!)
>
>and another change that may be a problem.

Here's a reproducible bug in barplot in 1.9.0 (based on an email I got
this morning from Richard Rowe):

x <- table(rep(1:5,1:5))
barplot(x)

The problem is that table() produces a one dimensional array, and
barplot() doesn't handle those properly now.  The offending line is
this one:

$ cvs diff -r 1.3 barplot.R
[junk deleted] 
43c43
<       width <- rep(width, length.out = NR * NC)
---
>       width <- rep(width, length.out = NR)

In the example above, x gets turned into a matrix with NR=1 row and
NC=5 columns so only one bar width gets set.

Duncan Murdoch




More information about the R-help mailing list