ronggui <ronggui.huang at gmail.com> writes:
> > x<-matrix(1:10,5)
> > x=t(x)
> > colnames(x) <- letters[1:5]
> > x
> a b c d e
> [1,] 1 2 3 4 5
> [2,] 6 7 8 9 10
>
> If I try to nest the above expressions,II get the error. I know there
> is something wrong with it(and I won't write command like that
> now),but I don't why.So anyone can explain it for me? Thank you!
>
> > x<-matrix(1:10,5)
> > colnames(t(x)) <- letters[1:5]
> Error: couldn't find function "t<-"
You're trying to modify x by modifying t(x), and there is no method to
do so. You can write one if you want:
> "t<-" <- function(x,value)"<-"(x,t(value))
> x<-matrix(1:10,5)
> colnames(t(x)) <- letters[1:5]
> x
[,1] [,2]
a 1 6
b 2 7
c 3 8
d 4 9
e 5 10
Of course, setting rownames(x) would be easier....
--
O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907