Hello again,

I have one question on subscripting matrix. Let say I have following matrix:

> Mat <- matrix(1:9, 3)
> colnames(Mat) <- c("a", "b", "a")
> Mat
     a b a
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9


Now I want to fetch data for colnames 'a'.I did following:

> Mat[, "a"]
[1] 1 2 3


However it is not taking second 'a' colume. Basically I expected to
get 1st and 3rd columns

Can somebody tell me how to achieve that?

Thanks and regards,

______________________________________________
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