[R] dimnames in class "by" object

utkarshsinghal utkarsh.singhal at global-analytics.com
Thu Aug 27 10:57:40 CEST 2009


Hi All,

 > d = data.frame(a=1:10,b=1:10)
 > by1 = rep(c("a","b"),5)
 > by(d, by1, function(z) z[,,drop=F])
by1: a
  a b
1 1 1
3 3 3
5 5 5
7 7 7
9 9 9
------------------------------------------------------------
by1: b
    a  b
2   2  2
4   4  4
6   6  6
8   8  8
10 10 10


 > by(d, by1, function(z) z[,1,drop=F])
[1] 1 3 5 7 9
------------------------------------------------------------
[1]  2  4  6  8 10

Can somebody explain why are the dimnames (i.e. by1: a   by1: b) not 
there this time.


Many Thanks
Utkarsh




More information about the R-help mailing list