13

I'm trying to get a list, sorted by frequency, from a data frame.

data <- read.csv('ads.csv')
write.table(summary(data$Publication.Name), quote = FALSE, sep = ",")

I'm not sure summary() is really the best way to get frequencies, I'm open to a better way. How can I sort this by most frequent first?

Tac Tacelosky
  • 3,165
  • 3
  • 27
  • 28
  • 2
    try `table` for frequencies. also make your [question reproducible.](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Jilber Urbina Nov 01 '13 at 12:51

1 Answers1

27

I would use table, for example

yourdata <- sample(1:10,100,replace=T) 
x <- sort(table(yourdata),decreasing=T)
write.csv(x,"mytable.csv",quote=F)
ndr
  • 1,427
  • 10
  • 11