[R] how to rename rows/columns of a matrix?

apjaworski@mmm.com apjaworski at mmm.com
Tue Jul 8 20:13:42 CEST 2003


This is what I would do:

cc <- NULL
for(i in 1:ncol(x)) cc <- c(cc, paste("X", i, sep=''))
colnames(x) <- cc

where x is your matrix.

Hope this helps,

Andy

__________________________________
Andy Jaworski
Engineering Systems Technology Center
3M Center, 518-1-01
St. Paul, MN 55144-1000
-----
E-mail: apjaworski at mmm.com
Tel:  (651) 733-6092
Fax:  (651) 736-3122


|---------+-------------------------------->
|         |           "David Andel"        |
|         |           <andel at ifi.unizh.ch> |
|         |           Sent by:             |
|         |           r-help-bounces at stat.m|
|         |           ath.ethz.ch          |
|         |                                |
|         |                                |
|         |           07/08/2003 11:22     |
|         |                                |
|---------+-------------------------------->
  >-----------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                             |
  |      To:       "R-Project" <r-help at stat.math.ethz.ch>                                                                       |
  |      cc:                                                                                                                    |
  |      Subject:  [R] how to rename rows/columns of a matrix?                                                                  |
  >-----------------------------------------------------------------------------------------------------------------------------|




Hi

I get a matrix with the columns named like "X13 X22 X1 X14 ...", i.e. not
successively. That has it's good reasons, but now how can I rename the
columns to "X1 X2 X3 ..."?

Thanks a lot,
David

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list