I have the following dataset pairs in id1 and id2 column which are all related to id 313. I am new to R and trying to find a solution that could link all those numbers to id