[R] Help: Beanplots calculating wrong average

joris meys jorismeys at gmail.com
Tue Nov 24 16:09:00 CET 2009


Hi,

The log of the mean is not the same as the mean of the logs, that's a
no-brainer. Guess you use the beanplot from the package with the same
name.

> beanplot(As1988,log="")
gives the correct plot.

Next time, could you provide a minimal code example we can run
ourselves? If we don't know what functions you're using, it's quite
impossible to say where the problem lies.

Cheers
Joris

On Tue, Nov 24, 2009 at 12:52 PM, Michael Hopgood
<michael.hopgood at mrm.se> 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.
>




More information about the R-help mailing list