naming rows and columns in a matrix
Please read the last line to every message to r-help. There is no code in your post so we have no idea what you did wrong.
x <- matrix(1:12, 3, 4, dimnames = list(letters[1:3], LETTERS[1:4])) x
A B C D a 1 4 7 10 b 2 5 8 11 c 3 6 9 12
rownames(x)
[1] "a" "b" "c"
colnames(x)
[1] "A" "B" "C" "D"
dimnames(x)
[[1]] [1] "a" "b" "c" [[2]] [1] "A" "B" "C" "D"
On Sun, Dec 28, 2008 at 12:43 PM, Math Girl <mathmathgurl at yahoo.com> wrote:
Hello,
I have a 3 x 7 matrix. I want to assign a name to each row
and each column. I tried using
dimnames, but for some reason I cannot retrieve the names of the rows or the names
of the columns. Is there another way to name the rows and columns and refer to them?
[[alternative HTML version deleted]]
______________________________________________ R-help at 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.