I have a defined character values and I need to replace them in another dataset.
Here is the sample dataset
data1 <- data.frame(id = c(1,2,3),
cat = c("A","B","C"))
> data1
id cat
1 1 A
2 2 B
3 3 C
data2 <- data.frame(v1 = c(1,1,2),
v2 = c(2,3,3),
score = c(15, 25, 35))
> data2
v1 v2 score
1 1 2 15
2 1 3 25
3 2 3 35
I would like to replace A
with 1
for eaxmple, how can I get the desired dataset below?
> data3
v1 v2 score
1 A B 15
2 A C 25
3 B C 35