[R] Assigning rank based on total count
ws
webb.sprague at gmail.com
Fri Jul 24 00:45:21 CEST 2009
Hi all,
I am using ACS micro data (PUMS) with one of the columns as a
factor for the place of birth (POBPF). I would like to create
a column (POBR) containing a rank
corresponding to the place of the observation
in the POBPF rankings. For example,
if a person is from Oregon, Oregon is
the most popular Place of Birth, so each
person who came from Oregon should have a 1
in their POBR. Each row from
California would have POBR 2, etc.
This way I can subset on the most populous sending
places when doing analyses.
For the life of me I can't figure this out.
I think some combination of "sort()",
"xtabs()" and "merge()" should work,
but my brain seems to be fried.
Tx
More information about the R-help
mailing list