Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206553

Is there a way to put a dataframe in the same order as another one in R

$
0
0

I have two dataframes (with 43 variables and 53 rows) from a survey, both have the same values but the rows are ordered in two random different ways.

Also, some rows have the same values as other rows. Here's an example:

DT1 <- data.frame(sex = c("M","F","M","M","F"),
                  Age = c(12,67,12,30,67),
                  V1 = c(7,7,6,6,7))

DT2 <- data.frame(sex = c("F","M","F","M","M"),
                  Age = c(67,12,67,12,30),
                  V1 = c(7,6,7,7,6))

My question is the following, is there a way to order the second dataframe as the first dataframe?


Viewing all articles
Browse latest Browse all 206553

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>