How to create new columns in a data.frame based on row values in R?
问题 Hej, I have a data.frame with family trios, and I would like to add a column with the full sibs of every "id" (= offspring). My data: df id dam sire 1: 83295 67606 79199 2: 83297 67606 79199 3: 89826 67606 79199 What I would like to retrieve: df2 id dam sire fs1 fs2 1: 83295 67606 79199 83297 89826 2: 83297 67606 79199 83295 89826 3: 89826 67606 79199 83295 83297 What I’ve tried: (similar to: How to transform a dataframes row into columns in R?) library(dplyr) library(splitstackshape) df2 <-