I execute the following code:
df<-data.frame(word=c("play","win","offer","http"),frequency=c(321,355,123,564),type=c("nonspam","nonspam","spam","spam"))
df=arrange(df,desc(frequency),desc(type))
df=df[order(df[,2],df[,3]),]
and the result is:
word frequency type
4 offer 123 spam
3 play 321 nonspam
2 win 355 nonspam
1 http 564 spam
but I want to sort the data frame with respect to frequency and type such as:
word frequency type
1 http 564 spam
4 offer 123 spam
2 win 355 nonspam
3 play 321 nonspam