I'm working with two data frames. I want the order of the rows one dataframe to match the orders of the rows in another dataframe.
For example:
terms_1 <- c("Cat", "Hat", "Dog", "Bat", "Mat", "Cow")
terms_2 <- c("Dog", "Cow", "Mat", "Cat", "Hat", "Bat")
terms_1_df <- data.frame(terms = terms_1, values = sample(seq(1,100, 1), replace = T, length(terms_1)))
terms_2_df <- data.frame(terms = terms_2, values = sample(seq(1,100, 1), replace = T, length(terms_2)))
> terms_1_df
terms values
1 Cat 22
2 Hat 47
3 Dog 91
4 Bat 48
5 Mat 60
6 Cow 46
> terms_2_df
terms values
1 Dog 94
2 Cow 35
3 Mat 68
4 Cat 21
5 Hat 67
6 Bat 60
I want the rows in terms_2_df rearranged to match the order of the terms rows in terms_1_df
Thank you!