[R] strange results in summary and IQR functions

John Kane jrkrideau at yahoo.ca
Wed Sep 9 16:49:05 CEST 2009


Have a look at ?IQR
  "Note that this function computes the quartiles using the quantile function rather than following Tukey's recommendations, i.e., IQR(x) = quantile(x,3/4) - quantile(x,1/4)."

It looks like boxplot() gives the results you expect.  

tt <- boxplot(x)
tt







--- On Tue, 9/8/09, Chunhao Tu <tu_chunhao at yahoo.com> wrote:

> From: Chunhao Tu <tu_chunhao at yahoo.com>
> Subject: [R]  strange results in summary and IQR functions
> To: r-help at r-project.org
> Received: Tuesday, September 8, 2009, 11:09 AM
> 
> Dear R users,
> Something is strange in summary and IQR. Suppose, I have a
> data set and I
> would like to find the Q1, Q2, Q3 and IQR.  
>  
> x<-c(2,4,11,12,13,15,31,31,37,47)
> > summary(x)
>    Min. 1st Qu.  Median   
> Mean 3rd Qu.    Max. 
>    2.00   11.25   14.00   20.30   31.00   47.00
> 
> > IQR(x)
> [1] 19.75
> However, I test the same data set in SAS "proc univariate",
> and SAS shows
> that Q1=11, Q2=14 and Q3=31. I think most of us agree that
> Q1 is 11 not
> 11.25. 
> 
> Could someone please explain to me why R shows Q1=11.25 not
> 11?
> 
> Many Thanks
> Tu
> 
> 
> -- 
> View this message in context: http://www.nabble.com/strange-results-in-summary-and-IQR-functions-tp25348079p25348079.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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.
> 


      __________________________________________________________________
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/




More information about the R-help mailing list