sgiannerini at gmail.com
2009-Mar-30 10:15 UTC
[Rd] quantile and IQR do not check for numeric input (PR#13631)
This report follows the post http://tolstoy.newcastle.edu.au/R/e6/devel/09/03/0760.html where it is shown that quantile() and IQR() do not work as documented. In fact they do not check for numeric input even if the documentation says : ?quantile x numeric vectors whose sample quantiles are wanted. Missing values are ignored. ?IQR x a numeric vector.> quantile(factor(1:9))0% 25% 50% 75% 100% 1 3 5 7 9 Levels: 1 2 3 4 5 6 7 8 9> IQR(factor(1:9))[1] 4> R.version_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status alpha major 2 minor 9.0 year 2009 month 03 day 26 svn rev 48224 language R version.string R version 2.9.0 alpha (2009-03-26 r48224) -- ______________________________________________________ Simone Giannerini Dipartimento di Scienze Statistiche "Paolo Fortunati" Universita' di Bologna Via delle belle arti 41 - 40126 =A0Bologna, =A0ITALY Tel: +39 051 2098262 =A0Fax: +39 051 232153 http://www2.stat.unibo.it/giannerini/
Thomas Lumley
2009-Mar-30 11:50 UTC
[Rd] quantile and IQR do not check for numeric input (PR#13631)
On Mon, 30 Mar 2009 sgiannerini at gmail.com wrote:> This report follows the post > > http://tolstoy.newcastle.edu.au/R/e6/devel/09/03/0760.html > > where it is shown that quantile() and IQR() do not work as documented.Nothing of the sort is shown! The thread argued that methods for these functions for ordered factors would be useful.> In fact they do not check for numeric input even if the documentation says > : > > ?quantile > x numeric vectors whose sample quantiles are wanted. Missing > values are ignored. > > ?IQR > > x a numeric vector. >The documentation says that you are not allowed to pass anything except a numeric vector to quantile() and IQR(). It doesn't, for example, say you can pass an arbitrary vector that will be checked to see if it is numeric. If you have code that passes a factor to IQR(), the bug is in that code. On the other hand, as someone else has since reported, the 'missing values are ignored' statement in ?quantile is wrong (or at least incomplete). -thomas Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle
Seemingly Similar Threads
- quantile(), IQR() and median() for factors
- strange results in summary and IQR functions
- 95% CI of a IQR and more
- Box plot with 5th and 95th percentiles instead of 1.5 * IQR: problems implementing an existing solution...
- How to pass value to an argument in a function which is an argument to the main function