[R] difference between "names", "colnames" and "dimnames"
Don MacQueen
macq at llnl.gov
Wed Jul 1 15:47:44 CEST 2009
I think your problem is with plotting, not with naming.
Tell the list what kind of plot you're doing
(with example code, of course) and where you need
to see names on the plot.
(What do you have in mind when you say names for
the "whole" matrix? There are row names, and
column names, and that's about it.)
-Don
At 6:08 PM -0500 6/30/09, Germán Bonilla wrote:
>Content-Type: text/plain
>Content-Disposition: inline
>Content-length: 1771
>
>Hi all...
>
>I built a matrix binding vectors with rbind, and have something like this:
>
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
>CLS 3.877328 4.087636 4.72089 4.038361 3.402942 2.786285 2.671222 3.276419
>ORD NaN NaN NaN NaN 5.770780 5.901113 11.888054 7.934823
>FAM NaN NaN NaN NaN NaN 3.699455 4.551196 2.885390
>GEN NaN NaN NaN NaN NaN 3.967411 4.390296 2.885390
>SPP NaN NaN NaN NaN NaN NaN NaN 2.885390
>
>Then I tried to assign names to each column with names(), but end up with
>the following:
>
>> names(tester) <-
>c("uno","dos","tres","cuatro","cinco","seis","siete","ocho")
>
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
>CLS 3.877328 4.087636 4.72089 4.038361 3.402942 2.786285 2.671222 3.276419
>ORD NaN NaN NaN NaN 5.770780 5.901113 11.888054 7.934823
>FAM NaN NaN NaN NaN NaN 3.699455 4.551196 2.885390
>GEN NaN NaN NaN NaN NaN 3.967411 4.390296 2.885390
>SPP NaN NaN NaN NaN NaN NaN NaN 2.885390
>attr(,"names")
> [1] "uno" "dos" "tres" "cuatro" "cinco" "seis" "siete" "ocho"
> [9] NA NA NA NA NA NA NA NA
>[17] NA NA NA NA NA NA NA NA
>[25] NA NA NA NA NA NA NA NA
>[33] NA NA NA NA NA NA NA NA
>
>I can use colnames(tester), but then I cannot identify the colnames on the
>points when I plot them.
>
>How can I set the names(tester) for the whole matrix?
>
>Thanks a lot.
>
>Germán,
>UNAM
>
> [[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.
--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
More information about the R-help
mailing list