[R] Barplot errors in MASS script

v.demart@libero.it v.demart at libero.it
Thu Jan 1 19:34:00 CET 2004

Reading "Modern Applied Statististics with S" and trying the corresponding
examples both in the book and in ../lib/R/library/MASS/script, I'm now trying
chapter 4 plotting bars with the following code on a linux box with R 1.8.1:
options(echo=T, width=65, digits=5)
lung.deaths <- aggregate(ts.union(mdeaths, fdeaths), 1)
barplot(t(lung.deaths), names = dimnames(lung.deaths)[[1]],
        main = "UK deaths from lung disease")
    legend(locator(1), c("Males", "Females"), fill = c(2, 3))

The legend doesn't look correct with respect to the picture at page 72 of the
book for two reasons:

1) The legend has a transparent background while in the book is "correctly"
opaque (and, above all, this is the background I expect!);

2) One of the two variables is represented in the legend with a different colour
from the same variable in the bars plot (green instead of yellow)

How could I set 1 and 2 right?

Thanks for your help


More information about the R-help mailing list