math | Mathematics‎ > ‎math | R‎ > ‎

math.r | Column / Row Names

http://stackoverflow.com/questions/2281353/row-names-column-names-in-r

R is more of an evolved rather than designed language, so these things happen. names() andcolnames() work on a data.frame but not on a matrix:

R> DF <- data.frame(foo=1:3, bar=LETTERS[1:3])
R> names(DF)
[1] "foo" "bar"
R> colnames(DF)
[1] "foo" "bar"
R> M <- matrix(1:9, ncol=3, dimnames=list(1:3, c("alpha","beta","gamma")))
R> names(M)
NULL
R> colnames(M)
[1] "alpha" "beta"  "gamma"
R> 

Comments