this thread relates to my last one posted, but with more data (see below). I want to match the partner ID with the partner (e.g. Susi should have the same pid as Hans). I would like to have a code, that is replicable for more data and more couples. Technocrat already recommended the "pair-function", with the limitation that it is only applicable for one couple.
I thought about the if-clause, but couldnt figure out what to insert to refer to that specific partners id:
Testfile1$pid[Testfile1$surname_p %in% Testfile1$surname & Testfile1$prename_p %in% Testfile1$prename] <-"partnerID"
I appreciate any help! Thanks
did pid partner prename surname prename_p surname surname_p
1 111 yes Susi Bauer Hans Maurer
2 222 no Peter Müller
3 333 no Christian Schneider
4 444 yes Hans Maurer Susi Bauer
5 555 no Maja Bäcker
6 666 no Robin Maler
7 777 yes Maria Spinner Ludwig Feuer
8 888 no Katrin Klopfer
9 999 yes Ludwig Feuer Maria Spinner