>>>>> "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.
Can you dig harder and if possible provide a reproducible (small..)
example to make progress here...
David> I *think* I've tracked it down to tapply() and/or
David> barplot() and have not seen anything in the NEWS file
David> regarding changes to these functions (as far a I can
David> see). As part of doing my homework, I would like to
David> read the version 1.8.1 help files for these two
David> functions, but now that I've upgraded I'm not sure
David> where I can find them. Is there a simple way for me
David> to get copies of these two help files to compare with
David> the versions in 1.9.0? As far as I can see,
David> barplot() and tapply() in 1.9.0 work as described in
David> their 1.9.0 help files (which does not surprise me).
David> I've been lurking on this list long enough to know
David> that if there has been a change it is documented, so
David> it must be that I just haven't found it yet. If
David> there hasn't been a change, then I am totally
David> perplexed, because I have been running this Sweave
David> file several times a day for the last few weeks and
David> have not changed that part of it (I've been changing
David> the LaTeX parts).
David> In the part of the code that has changed I use
David> tapply() to summarise some data and then plot it with
David> barplot(). I now have to use matrix() on the output
David> of tapply() before using barplot() because tapply()
David> produces a list and barplot() wants a vector or
David> matrix.
David> In the code below, z is a dataframe, yllperdth is a
David> numeric and fld is the name of a factor, both in the
David> dataframe.
David> Old version (as used with R 1.8.1):
David> ## Calculate the % of YLLs for each group in the
David> cause classification. x <- tapply(z$yllperdth, z[,
David> fld], sum) totalYLLs <- sum(x) x <- x / totalYLLs *
David> 100 x <- sort(x)
David> ## Plot the chart. horiz = TRUE makes it a bar
David> instead of ## column chart. las = 1 prints the
David> labels horizontally. xplot <- barplot(x, horiz David>
TRUE, xlab = "Percent of YLLs", las = 1)
David> New Version (as used with R 1.9.0):
David> ## Calculate the % of YLLs for each group in the
David> cause classification. x <- tapply(z$yllperdth, z[,
David> fld], sum) totalYLLs <- sum(x) x <- x / totalYLLs *
David> 100 x <- sort(x)
David> causeNames <- names(x) ## NEW BIT x <- matrix(x) ##
David> NEW BIT
David> ## Plot the chart. horiz = TRUE makes it a bar
David> instead of ## column chart. las = 1 prints the
David> labels horizontally. xplot <- barplot(x, beside David>
TRUE, ## NEW BIT names.arg = causeNames, ## NEW BIT
David> horiz = TRUE, xlab = "Percent of YLLs", las = 1)
>> version
David> _ platform i686-pc-linux-gnu arch i686 os
David> linux-gnu system i686, linux-gnu status major 1 minor
David> 9.0 year 2004 month 04 day 12 language R
David> A little while before upgrading I noted my previous R
David> version (for a post that I redrafted 7 times and
David> never sent because I found the answer through
David> refining my draft), and it was:
>> version
David> _ platform i686-pc-linux-gnu arch i686 os
David> linux-gnu system i686, linux-gnu status Patched major
David> 1 minor 8.1 year 2004 month 02 day 16 language R
David> So, can I get the old help files? Or it is easy to
David> point me to a documented change? Or is it clear from
David> my code what has changed or what I am or was doing
David> wrong?
David> Thanks.
David> Dave
David> -- David Whiting Dar es Salaam, Tanzania