Is there a standard way to sort data.frame across multiple columns, but with changes to decrease or increase? For example, you can order the data.frame file by one variable (decreasing) and the next (increasing).
Is there something like:
mydf[ order(mydf$myvariable,mydf$myvariable2,decreasing=c(FALSE,TRUE)), ]
library(plyr) mydf[with(mydf, order(myvariable, desc(myvariable2)), ] # Or, a little less typing: arrange(mydf, myvariable, desc(myvariable2))
Quick workaround:
mydf[ order(mydf$myvariable,-mydf$myvariable2,decreasing=F), ]
For factors, rows, etc .:
mydf[ order(mydf$myvariable,-xtfrm(mydf$myvariable2),decreasing=F), ]
library(Deducer) sort(mtcars,by = ~ cyl - mpg)
Source: https://habr.com/ru/post/1316634/More articles:Android minSdkVersion = 3, but the application is not available for Android Android devices from Android? - androidwarning of failure (assemblies) after a transaction with NHibernate - nhibernateConverting from XML to PLIST - c #hashmap java based drive - javaHow to force use a specific XML parser - javaCan unused namespace directives cause any changes? - memory-managementthe flying saucer (xhtmlrenderer) doesn't dare my font? - javaRecommendations for Open Source AJAX Lightweight Library in Javascript - javascriptAdding a new line to console output - vb.netActiveMQ messagedriven bean for JSF - javaAll Articles