Re: [R] lost attrubute:names

2008-08-28 Thread Charles C. Berry
On Thu, 28 Aug 2008, Yuan Jian wrote: Hi, when I pick out one element from a matrix, the attribute name is kept, but when more than one elements are extracted, the attribute name lost; To what attribute 'name' do you refer? I only see 'dim' and 'dimnames' attributes: attributes(a) $dim [1]

[R] lost attrubute:names

2008-08-28 Thread Yuan Jian
Hi, when I pick out one element from a matrix, the attribute name is kept, but when more than one elements are extracted, the attribute name lost;   >a<-matrix(c(1,2,3,11,12,13,45,56,76),ncol=3,dimnames=list(c(),c("c1","c2","c3"))) > k<-a[a[,"c3"]>50,"c3"] > kk<-a[a[,"c3"]>60,"c3"] > attributes(k)