[R] Sorting data frame by prepared order

jeff6868 geoffrey_klein at etu.u-bourgogne.fr
Mon Mar 2 13:02:53 CET 2015


Maybe a beginning of solution with this?

test <-

out <- split(test,test$x)

for (i in 1:length(out)) {
    foo <- unique(out[[i]][,2])
       out[[i]][,2] <- rep(foo,(nrow(out[[i]])/(length(foo)))) }

Seems to work for an length with a even value of your unique values in your
first column. But still a problem for odd lengths. Maybe solved by adding
fake rows that you can remove afterwords (with a specific index for

View this message in context: http://r.789695.n4.nabble.com/Sorting-data-frame-by-prepared-order-tp4704038p4704058.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list