[Rd] small inconistency: sapply & median (PR#702)

jutans@utans.u-net.com jutans@utans.u-net.com
Mon, 23 Oct 2000 21:13:04 +0200 (MET DST)


Full_Name: Joachim Utans
Version: 1.1.1
OS: NT4 (SP6)
Submission from: (NULL) (195.102.198.233)


There seems to be a small inconsistency with using median in sapply with
handling names (looks like it has to do with the different handling when the
length is even/odd)
Specifically, sapply will concatenate listelement names and a member name if the
length of the member is odd.
Example follows:

> TMP.list_list(item1=c(a1=1,a2=2,a3=3), item2=c(b1=1,b2=2))
> TMP.list
$item1
a1 a2 a3
 1  2  3

$item2
b1 b2
 1  2

> sapply(TMP.list, mean)
item1 item2
  2.0   1.5
> sapply(TMP.list, median)
item1.a2    item2            !!!!!!!!!!!! note the ".a2"
     2.0      1.5
>

> sapply(TMP.list, median, USE.NAMES=F)
item1.a2    item2
     2.0      1.5
> lapply(TMP.list, median)
$item1
a2
 2

$item2
[1] 1.5




-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._