[R] Rownames are always character?

Mike Prager mike.prager at noaa.gov
Fri Mar 16 23:21:33 CET 2007


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).

I am using elements of the returned vector to index the matrix.

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