# [R] order

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Jul 3 17:05:08 CEST 2001

```On Tue, 3 Jul 2001 tomsv193 at student.liu.se wrote:

> Why is the rows-indicies effected by ordering?

Those are row names, not row indices.

> Example:
>
> (data=)
>   name   age
> 1 peter  13
> 2 eric   15
> 3 daniel 14
>
> #ordering by name...
>
>   name   age
> 3 daniel 14
> 2 eric   15
> 1 peter  13
>
> why not:
>
>   name   age
> 1 daniel 14
> 2 eric   15
> 3 peter  13
>
> Does it effect other operations? data[,1] really gives the 1:st row,
> but when data is printed it says that the first row have index 3...

*row name* 3.  Indices are printed like [3,] as in

> matrix(1:9, 3)
[,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9

Try a data frame like swiss with real names (in 1.3.0) rather than names
which happen to be 1:nrow(df).

--
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```