[R] defining columns in a matrix
(Ted Harding)
Ted.Harding at manchester.ac.uk
Fri Mar 12 23:56:57 CET 2010
On 12-Mar-10 22:29:07, Kindra Martinenko wrote:
> Hi all,
> I have the following 7 x 7 matrix. _I am trying to figure out
> how to label the columns to something more descriptive other
> than [,1], [,2], etc.
> I have tried the c(x,y,z,) function, but I get a error returned
> stating that my vectors need to be the same length. Do I need to
> convert this to something else such as a list and then repack it?
>
> Thanks,
> Kindra
>
> Volume
> Time [,1] [,2] [,3] [,4] [,5] [,6] [,7]
> 17:00:00 7146 4926 5394 4534 6273 6192 6189
> 17:10:00 7227 4851 5414 4620 6026 7159 5878
> 17:20:00 7477 4678 5502 4298 6516 6469 5631
> 17:30:00 6533 4608 4813 4212 6083 5837 5657
> 17:40:00 6355 4669 5106 4242 5717 5635 5282
> 17:50:00 5657 4472 4545 3860 5378 4804 5304
> 18:00:00 5338 4508 4273 4024 4666 4597 5162
Let M denote your matrix. Then you can easily give the columns
names by a command like
colnames(M) <- c("Vol1","Vol2","Vol3","Vol4","Vol5","Vol6","Vol7")
It looks as though you have already labelled the rows (with the
Time values) since you say it is a 7x7 matrix. It's not clear what
command you actually tried (you only say that you "tried the
c(x,y,z,) function"). If you state what the full command was, it
may be possible to explain the error message you got.
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 12-Mar-10 Time: 22:56:53
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list