I have two datasets that have a different number of cases, but the same number of variables. E.g., this:
test_data <- data.frame(
var_1 = rep(1, 10),
index = letters[1:10]
)
other_data <- data.frame(
var_1 = c(1, 1, 3, 4, 6, 1),
index = letters[1:6]
)
And what I need is to replace the values in var_1
in test_data
with the values of var_1
in other_data
. So the end result would look like this:
> test_data
var_1 index
1 1 a
2 1 b
3 3 c
4 4 d
5 6 e
6 1 f
7 1 g
8 1 h
9 1 i
10 1 j
I know that dplyr
is nice to work with relational data, but I can't figure out whether it's one of the _join
function that would do it for me, or something different? Thanks.