club2 <- data.frame(club_id = 1:6, mem2 = c(1000, 700, 80, 516, 20, 211))
match <- read.csv("https://www.dropbox.com/s/nc98i784r91ugin/match.csv?dl=1")
那么,对于专栏
mem2
,我检查它是否存在于
match$rn
. 如果不是这样,则插入NA。如果是这样的话,它会插入
match$id
-在那个位置的那个
匹配$rn
内存2
club2$mem2 <- ifelse(club2$mem2 %in% match$rn == TRUE, match$id[match(club2$mem2, match$rn)], NA)