[R] assign names to matrix
Uwe Ligges
ligges at statistik.uni-dortmund.de
Thu Nov 16 18:37:45 CET 2000
On Thu, 16 Nov 2000 Pan_Yuming at aam.de wrote:
>
> Thanks for your advice.
>
> My interest is to how to refer to each column as if it is a variable. i
> solved this problem by
> dimnames(v) <- list(1:nrow(v),label)
> v <- as.data.frame(v)
>
> now i can refer to column 1 of v as v$A...
That's not neccessary.
Why don't you use:
matrixname[,colname]
e.g.:
my.matrix <- matrix(1:16, nrow=4)
my.matrix
my.matrix[,1]
Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list