I am working on a tennis data set. I have a table of number of lost matches by player with 384 rows. I have a table of number of won matches by player with 287 rows. I want to create a column j where I can add the two-column 'n' if a player is in both tables. If not I want to add 0. Here is the code, but it doesn't work
for (i in num_match_l$Loser){
num_match_l$b <-num_match_l$n + ifelse(i %in% num_match_w$Winner, num_match_w$n, 0)
}