[R] row.names need reordering

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon May 16 08:07:29 CEST 2005


On Mon, 16 May 2005, Anders Schwartz Corr wrote:

> The row.names in my matrix seem to be out of order. I don't remember
> putting row.names in in the first place, I don't see what use they are,
> and they are out of order (perhaps because I sorted them at one point when
> the data was in data.frame format). Can I delete the rownames? or at least
> just reorder them in proper order? I know how to delete them -- how do I
> reorder them sequentially?

Matrices strictly have rownames, data frames row.names.  So try

rownames(A) <- seq(len=nrow(A))

(to delete them, use NULL as the rhs).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list