假设有两个数据帧:A和B.
Dataframe: A Dataframe: B
ColA1 ColA2 ColB1 ColB2
| Dog | Peter| | Lion | Bob |
| Lion | Bob | | Cat | NA |
| Zebra | Jim | | Tiger| NA |
| Bat | Robin| | Dog | Peter |
我想这样做:
B$ColB2 <- ifelse((B$ColB1 %in% A$ColA1), "Name from col A" , NA)