[Rd] names of return value of median

From: Vadim Organovich <vogranovich_at_jumptrading.com>
Date: Wed, 20 Aug 2008 12:30:38 -0500

Dear R-devel,

The median() function assigns a name, "NA", to its return value if the return value is NA and the input vector has names, otherwise the names attribute is NULL. This looks strange and inconsistent with the behavior of mean().

This inconsistency becomes a problem when median() is used inside user code that relies on consistent naming convention.


> foo <- c(x=as.numeric(NA), y=as.numeric(NA), z=as.numeric(NA))
> names(mean(foo))

> names(median(foo))

[1] NA

## no names in input
> foo <- rep(as.numeric(NA), 3)
> names(median(foo))

> version

platform       i386-pc-mingw32
arch           i386
os             mingw32
system         i386, mingw32
major          2
minor          7.1
year           2008
month          06
day            23
svn rev        45970
language       R

version.string R version 2.7.1 (2008-06-23)

Note: This email is for the confidential use of the named addressee(s) only and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you are hereby notified that any review, dissemination or copying of this email is strictly prohibited, and to please notify the sender immediately and destroy this email and any attachments. Email transmission cannot be guaranteed to be secure or error-free. Jump Trading, therefore, does not make any guarantees as to the completeness or accuracy of this email or any attachments. This email is for informational purposes only and does not constitute a recommendation, offer, request or solicitation of any kind to buy, sell, subscribe, redeem or perform any type of transaction of a financial product.

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 20 Aug 2008 - 17:33:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 21 Aug 2008 - 08:37:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive