first dataset.
merge_field is the field without any tidyr::fill operations done. the name of column represents which fill operation is done.
name country merge_field merge_field_down merge_field_downup merge_field_up
Anna USA CA CA CA CA
Anna USA NA CA CA NA
Anna BRA NA CA CA NA
Anna BRA NA CA CA NA
Ryan USA NA NA PT PT
Ryan USA PT PT PT PT
Ryan USA NA PT PT NA
Liam MEX NA NA OX OX
Liam MEX OX OX OX OX
Liam MEX NA OX OX NA
Liam MEX NA OX OX NA
Liam MEX NA OX OX NA
second dataset
name country merge_field merge_field_right
Anna USA CA merge_field_down
Ryan USA PT merge_field_up
Liam MEX OX merge_field_downup
the second dataset tells me what tidyr:fill grouping we want to keep for the name and country combination in the first dataset. we group by name in this dataset.
for example for "Anne USA CA" we need to use the grouping in merge_field_down column.. For "Ryan USA PT" we need to use the grouping in merge_field_up.
desired output data set
name country merge_field_right_value merge_field_right
Anna USA CA merge_field_down
Anna USA CA merge_field_down
Anna BRA CA merge_field_down
Anna BRA CA merge_field_down
Ryan USA PT merge_field_up
Ryan USA PT merge_field_up
Ryan USA NA merge_field_up
Liam MEX OX merge_field_downup
Liam MEX OX merge_field_downup
Liam MEX OX merge_field_downup
Liam MEX OX merge_field_downup
Liam MEX OX merge_field_downup
Liam MEX OX merge_field_downup
is there any easy way to do this. I know this is quite complicated. thanks.