On Mar 12, 2010, at 5:29 PM, 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

I suspect that is a zoo object, a special sort of matrix. Your questions would be more clear if instead of presenting the results of the print command you would instead present the results of dput(object).

The answers you have gotten so far will work if it is a zoo object
> z2 <- zoo(matrix(1:12, 4, 3), as.Date("2003-01-01") + 0:3)
>
> z2

2003-01-01 1 5  9
2003-01-02 2 6 10
2003-01-03 3 7 11
2003-01-04 4 8 12
> is.matrix(z2)
[1] TRUE
> colnames(z2) <- c("one", "two", "three")
> z2
          one two three
2003-01-01   1   5     9
2003-01-02   2   6    10
2003-01-03   3   7    11
2003-01-04   4   8    12

> class(z2)
[1] "zoo"




David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to