Skip to content
Prev 258517 / 398502 Next

Sorting dataframe by number of occurrences of factor

df<-data.frame(id=c(1:20),name=c('a','b','b','c','a','d','b','e','d','d','c','a','b','a','a','b','f','b','c','g')) 
freq <- ave(rep(1, times=nrow(df)), df$name, FUN=sum) 
rowSums(table(df$name,freq))
--
View this message in context: http://r.789695.n4.nabble.com/Sorting-dataframe-by-number-of-occurrences-of-factor-tp3485443p3486088.html
Sent from the R help mailing list archive at Nabble.com.