I have a dataset with paired data (members of the same household).
Id is an individual identifier, and homeid is a partner identifier (and vice versa).
I need to add an additional column (lesson) for each id of my partner.
My data is as follows
dta = rbind( c(1013661,101366, 'Never worked'), c(1013662, 101366, 'Intermediate occs'), c(1037552, 103755, 'Managerial & professional occs'), c(1037551, 103755, 'Intermediate occs') ) colnames(dta) = c('idno', 'householdid', 'occup') dta idno householdid occup "1013661" "101366" "Never worked" "1013662" "101366" "Intermediate occs" "1037552" "103755" "Managerial & professional occs" "1037551" "103755" "Intermediate occs"
What I need should look like this:
idno householdid occup occupPartner "1013661" "101366" "Never worked" "Intermediate occs" "1013662" "101366" "Intermediate occs" "Never worked" "1037552" "103755" "Managerial & professional occs" "Intermediate occs" "1037551" "103755" "Intermediate occs" "Managerial & professional occs"
I think there is a solution with a mutation, but I'm not sure what group_by is.
Any ideas?
source share