I have two data frames with matching cells.
v <- data.frame(c1=c(30,15,3), c2=c(10,25,2), c3=c(20,35,4))
w <- data.frame(c1=c("thirty","fifteen","three"), c2=c("ten","twenty-five","two"), c3=c("twenty","thirty-five","four"))
I need to sort each row of both without resorting to (slow) loops. To sort v
(which will determine the order of the other data frame too) I use the method recommended here:
v.sorted <- t(apply(v, 1, sort))
How can I manipulate data frame w
so that it matches the sorted version of v
?
Thanks in advance!