[R] Rownames are always character?

Mike Prager mike.prager at noaa.gov
Fri Mar 16 23:26:41 CET 2007

Mike Prager <mike.prager at noaa.gov> wrote:

> Gurus,
> Can I rely on the rownames() function, when applied to a matrix,
> always returning either NULL or an object of type character?  It
> seems that row names can be entered as integers, but as of now
> (R 2.4.1 on Windows) the function returns character vectors, not
> numbers (which is my desired result).

(To clarify my point on this Friday afternoon:  the observed
behavior is my desired result.  I'm just asking, can I count on

> I am using elements of the returned vector to index the matrix.
> e.g.,
> nams <- rownames(mymat)
> for (thisnam in nams) {
> 	myvec <- mymat[thisnam, ]
> 	# ... more code ...
> }

Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

More information about the R-help mailing list