How do I arrange data frame by decreasing order of values in column value
where values in column "cat"=X
ex. data frame
df1<-data.frame(group=rep(c("A", "B", "C", "D"),each=2), cat=rep(c("X", "Y"),4), value=c(1,0.6,1,0.5,1,2,1,5))
ex. rearranged data frame (that I want to see):
I tried df1[with(df1, order(-value, cat)),]
after reviewing the first answer on this article, but it did not work, the result is below:
As you can see the two tables look different. I tried arrange command from dplyr
package too but every result looks like the one above.
Thank you