it pays to check out old emails sometimes ;)
-----Original Message-----
From: gov1000-list-admin(a)fas.harvard.edu
[mailto:gov1000-list-admin@fas.harvard.edu] On Behalf Of Dave Kane
Sent: Sunday, December 08, 2002 1:08 PM
To: Phillip Y. Lipscy
Cc: gov1000-list(a)fas.harvard.edu
Subject: [gov1000-list] sorting dataframes/matrices
help(sort) points you to "order". Check out the help. Here is an
example:
x
a b
1 1 o
2 2 c
3 3 x
4 4 h
5 5 f
x[order(x$b),]
a b
2 2 c
5 5 f
4 4 h
1 1 o
3 3 x
x[order(x$a),]
a b
1 1 o
2 2 c
3 3 x
4 4 h
5 5 f
Dave
Phillip Y. Lipscy writes:
> Dear all,
> sort() works nicely for vectors but not
for dataframes and matrices
(for
matrices it doesn't sort by columns properly).
Since even ms excel
can sort
dataframes by columns, I'm assuming R can do that
too, but so far I
haven't
> found anything that seems to let me do that. Any ideas?
> Thanks,
> Phillip.
>
-------------------------------------------------
> Phillip Y. Lipscy
> Perkins Hall Room #129
> 35 Oxford Street
> Cambridge, MA 02138
> (617)493-4893
> lipscy(a)fas.harvard.edu
> Ph.D. Candidate
> Harvard University, FAS, Department of Government
> -------------------------------------------------
>
_______________________________________________
> gov1000-list mailing list
> gov1000-list(a)fas.harvard.edu
>
http://www.fas.harvard.edu/mailman/listinfo/gov1000-list
--
David Kane
Lecturer in Government
617-563-0122
dkane(a)latte.harvard.edu
_______________________________________________
gov1000-list mailing list
gov1000-list(a)fas.harvard.edu
http://www.fas.harvard.edu/mailman/listinfo/gov1000-list