Re: [R] Assigning rank based on total count

2009-07-27 Thread ws
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. I wrote a blog entry on my solution:

[R] Assigning rank based on total count

2009-07-23 Thread ws
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

Re: [R] Assigning rank based on total count

2009-07-23 Thread ws
Here's a way to get to your solution, but it's not very pretty: testdfr - data.frame(POB=c(Oregon,Oregon,Oregon,New York,California,California)) nstates - length(unique(testdfr$POB)) testdfr$ POBR - c(nstates:1)[table(testdfr$POB)][testdfr$POB] Hmm I will have to think on that for

Re: [R] Assigning rank based on total count

2009-07-23 Thread Remko Duursma
Here's a way to get to your solution, but it's not very pretty: testdfr - data.frame(POB=c(Oregon,Oregon,Oregon,New York,California,California)) nstates - length(unique(testdfr$POB)) testdfr$ POBR - c(nstates:1)[table(testdfr$POB)][testdfr$POB] greetings, Remko