[R] Assigning rank based on total count

ws webb.sprague at gmail.com
Fri Jul 24 02:54:43 CEST 2009


> 
> 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 a while....  An ugly
solution is still better than no solution, but that doesn't quite 
make sense to me yet.




More information about the R-help mailing list