I actually had to do the same exact thing for my causal inference
homework. Sorting a vector is easy--just sort(x)--but sorting a
dataset requires a different command.
# Sorting dataframe by propensity vector
# Order of vector of props
index <- order(dat$props)
# New sorted dataset
dat.sort <- dat[index,]
Get more sleep,
Jon
On Mon, Apr 28, 2008 at 3:34 AM, John Sheffield
<john.sheffield at gmail.com> wrote:
Silly question:
How does one sort a dataframe such that it only sorts on the characteristics
of the first column and preserves each row as an intact unit? I.e., I have a
vector of propensity scores in column one that I want sorted, but the
propensity score corresponds to other variables in columns 2-8 that must
remain connected to those scores.
Thanks!
John
_______________________________________________
gov2001-l mailing list
gov2001-l at
lists.fas.harvard.edu
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
--
Jon Bischof
Graduate Student
Department of Government
Harvard University