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: [EMAIL PROTECTED]
Tel:  (651) 733-6092
Fax:  (651) 736-3122


|---------+-------------------------------->
|         |           "David Andel"        |
|         |           <[EMAIL PROTECTED]> |
|         |           Sent by:             |
|         |           [EMAIL PROTECTED]|
|         |           ath.ethz.ch          |
|         |                                |
|         |                                |
|         |           07/08/2003 11:22     |
|         |                                |
|---------+-------------------------------->
  
>-----------------------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                                         |
  |      To:       "R-Project" <[EMAIL PROTECTED]>                                     
                                  |
  |      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

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to