[Rd] fivenum (PR#4586)
Dirk Eddelbuettel
edd at debian.org
Wed Oct 15 01:38:32 MEST 2003
On Wed, Oct 15, 2003 at 01:20:04AM +0200, r.huggins at latrobe.edu.au wrote:
> Full_Name: Richard Huggins
> Version: 1.7.1
> OS: windows 2000
> Submission from: (NULL) (131.172.4.44)
>
>
> > x<-rnorm(100,2,1)
> > mean(x)
> [1] 1.73299
> > summary(fivenum(x))
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> -0.3655 1.1070 1.7430 1.7320 2.3840 3.7910
> > summary(x)
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> -0.3655 1.1070 1.7430 1.7330 2.3830 3.7910
> > y<-log(abs(x))
> > summary(fivenum(y))
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> -3.5950 0.1020 0.5555 -0.1472 0.8688 1.3330
> > mean(y)
> [1] 0.2878568
> > summary(y)
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> -3.5950 0.1021 0.5555 0.2879 0.8683 1.3330
>
>
> summary(fivenum(x)) gives the wrong mean
I think you may be misunderstanding what is happening -- fivenum() returns a
simple vector of five numbers, which summary then summarises.
It so happens that for an (approx.) symmetrically distributed sample x as
the one you drew from the N(2,1), mean(summary(x)) is still approx. mean(x)
(and identical asymptocally). That no longer holds once you take
logs(abs()). As so often, it helps to simply plot the data as you could with
> boxplot(x,summary(x),fivenum(x),y,summary(y),fivenum(y),horizontal=TRUE)
Hth, Dirk
--
Those are my principles, and if you don't like them... well, I have others.
-- Groucho Marx
More information about the R-devel
mailing list