Skip to content
Prev 294969 / 398506 Next

Sort across multiple csv

Hello,

Try the following.


# Make some data
alldata <- list(matrix(rnorm(12), ncol=3), matrix(sample(100), ncol=10))
(alldata <- lapply(alldata, function(x){colnames(x) <- c("Name",
LETTERS[2:ncol(x)]); x}))

# This does the trick
all.order <- lapply(alldata, function(x) order(x[, "Name"]))
lapply(seq.int(length(alldata)), function(i) alldata[[i]][all.order[[i]], ])


Hope this helps,

Rui Barradas

BustedAvi wrote
--
View this message in context: http://r.789695.n4.nabble.com/Sort-across-multiple-csv-tp4630531p4630537.html
Sent from the R help mailing list archive at Nabble.com.