Skip to content
Prev 201725 / 398506 Next

Help: Beanplots calculating wrong average

Hi Tom,

Thank you for the friendly and informative answer.  It does explain a lot of
things, actually.  As with any good answer, it inevitably leads to other
questions.  In the first place, I need the arithmetic mean.  It's what we
base our calculations on...

My code is currently this:

Metall<-c("Cu","Cu","Cu","Cu","Cu","Cu","Cu","Cu","Cu","Cr","Cr","Cr","Cr","
Cr","Cr","Cr","Cr","Cr","As","As","As","As","As","As","As","As","As","Pb","P
b","Pb","Pb","Pb","Pb","Pb","Pb","Pb","Zn","Zn","Zn","Zn","Zn","Zn","Zn","Zn
","Zn")
Halt<-c(85,13,13,340,18,13,88,24,12,216,33,21,454,20,18,88,30,21,1254,22,4.2
,1081,35,6,1772,192,7.6,43,20,12,3107,21,12,30,24,19,1109,57,46,269,68,50,58
5,131,52)
beanplot(Halt~Metall, log = "y", yaxt = "n", ylab="Halt
(mg/kg)",cex.lab=1.2)
axis(2,c(1,10,100,1000,10000))
polygon(c(0.2966510,0.2966510,1.4832033,1.4832033,3.6160162,3.6160162,4.4921
444,4.4921444,5.6968371,5.6968371),c(2.763021e-01,10,10,80,80,40,40,250,250,
2.763021e-01),col="#66FF0090", border="#66FF0090")
text(5.58,10,"<KM", cex=1.2, font=2)
polygon(c(0.2966510,0.29665101,1.4832033,1.4832033),c(10,25,25,10),col="#FFF
F0090",border="#FFFF0090")

polygon(c(1.4832033,1.4832033,2.5027348,2.5027348,3.6160162,3.6160162,4.4921
444,4.4921444,5.6968371,5.6968371,4.4921444,4.4921444,3.6160162,3.6160162,1.
4832033),c(80,150,150,200,200,400,400,500,500,250,250,40,40,80,80),col="#FFF
F0090",border="#FFFF0090")
text(5.54,350,"<MKM", cex=1.2, font=2)
polygon(c(0.2966510,0.2966510,5.6968371,5.6968371,4.4921444,4.4921444,3.6160
162,3.6160162,2.5027348,2.5027348,1.4832033,1.4832033),c(25,30085.997183,300
85.997183,500,500,400,400,200,200,150,150,25),col="#FF000090",border="#FF000
090")
text(5.54,2500,">MKM", cex=1.2, font=2)


The polygons convey information on whether each sample is higher than the
soil guideline value.  If I take away, the log scale, the vast difference in
values obscures the polygons...  Ideally I'd like the average beanline to be
the arithmetic mean or to be gone altogether. Can't seem to make beanplot do
this...

Sincerely,
Michael Hopgood 





-----Ursprungligt meddelande-----
Fr?n: Tom Wainwright [mailto:Thomas.Wainwright at noaa.gov] 
Skickat: den 24 november 2009 18:43
Till: Michael Hopgood
Kopia: r-help at r-project.org
?mne: Re: [R] Help: Beanplots calculating wrong average

Hi Michael,

Looking at the help for beanplot(), note that the 'log' option defaults to 
'auto' which means the function will automatically log-transform data like 
yours.  This also implies that the mean it shows is the geometric mean, not
the 
arithmetic mean.  As you note, the transformation doesn't affect the median.

If you don't want this behavior, I think setting log="" will do the trick.

Hope this helps.

	Tom Wainwright
On 11/24/2009 03:52 AM, Michael Hopgood wrote:
now
function
http://www.R-project.org/posting-guide.html