[R] assign names to matrix

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Nov 16 18:18:05 CET 2000

Pan_Yuming at aam.de writes:

> 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...

Um, you're crossing the creek to fetch water:

v <- as.data.frame(v)
names(v) <- label

(and if I remember correctly you asked how to read this from a file.
Using read.table('filename') gives you a data frame right away, but
you were asking how to read it as a matrix...)

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
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