I have a dataframe that I want to replace some of its values using another dataframe which I have row, column, and value information.
dat <- data.frame(Age = c(19,22,32,24),Names = c("Bobby","Mary","Bill","Chuck"), Sport = c("Golf","Tennis","Football","Soccer"))
Age Names Sport
19 Bobby Golf
22 Mary Tennis
32 Bill Football
24 Chuck Soccer
valuesreplace <- data.frame(row = c(1,3), column = c(3,1), value = c("Basketball","18"))
row column value
1 3 Basketball
3 1 18
The result should be the following:
Age Names Sport
19 Bobby Basketball
22 Mary Tennis
18 Bill Football
24 Chuck Soccer