[R] Help: Beanplots calculating wrong average
Tom Wainwright
Thomas.Wainwright at noaa.gov
Tue Nov 24 18:43:03 CET 2009
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:
> Hi there,
>
> I have a set of data that looks like this:
>
> As1988<-c(1254.0, 22.0, 4.2, 1081.0, 35.0, 6.0, 1772.0, 192.0, 7.6)
>
> The mean of this (as calculated by R) is: 485.9778
>
> The median of this (as calculated by R) is: 35
>
>
>
> If I then make a beanplot(As1988), I find that the beanline (average) is now
> 77.68561 while the beanline (median) is 35.39739 (using the locator function
> to check the graph and log axis).
>
>
>
> While I can understand the small discrepancy of the median(mouse hovering
> over the line), I am at a loss to explain the huge difference between the
> means. Is this a flaw in the package or is there something I am missing?
>
>
>
> My gut feeling is that the log scales are affecting the calculations
> somehow.
>
>
>
> Sincerely,
>
> Michael Hopgood
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Tom Wainwright
NOAA Northwest Fisheries Science Center
Newport, Oregon
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The contents of this message are mine personally and do not necessarily
reflect any position of the Government or the National Oceanic and
Atmospheric Administration.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
More information about the R-help
mailing list