id first second third fourth
1 A BX <NA> <NA> LG
2 A <NA> TD <NA> QR
3 B <NA> BZ RB <NA>
4 B LF <NA> BT <NA>
and merge rows based on the id, such that the value in the column will be
one of four possibilities: if both values in the original df are <NA>, the
new value should also be <NA>. If there are two non-NA values, then the
new value should read "clash". Otherwise, the new value should be
whichever value was not <NA>.
An example output from the command would read in df and read out:
id first second third fourth
1 A BX TD <NA> clash
2 B LF BZ clash <NA>
I'd be grateful if someone could point me in the right direction.
Thanks,
Jonathan