[R] Rownames are always character?
Charilaos Skiadas
skiadas at hanover.edu
Sat Mar 17 02:43:46 CET 2007
On Mar 16, 2007, at 6:26 PM, Mike Prager wrote:
> 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
> it?)
I would venture to guess that rownames() would always be returning
something that you would then be able to use for indexing, to
retrieve particular entries. The help page also implies that the
return value will always be a character vector, or NULL:
"If do.NULL is FALSE, a character vector (of length NROW(x) or NCOL
(x)) is returned in any case, prepending prefix to simple numbers, if
there are no dimnames or the corresponding component of the dimnames
is NULL."
I would think you can count on this about as much as you can count
the sum function to always add up its arguments, or something of that
sort.
Haris Skiadas
Department of Mathematics and Computer Science
Hanover College
More information about the R-help
mailing list