I have a dataset which looks something like this:
https://i.stack.imgur.com/5W0HU.png
I want to compare all columns based on 'Agentdepartment'. If values are same, then pick it up as it is, if different then concatenate both the values via a '/', and then delete the lower row. In case of NA, I don't want them to be coalesced,i.e if one columns has Null and other non null, keep the non null value.If both are having NULL then keep NULL. So I want a single row for every department. This is how I want my final dataset to look like:
https://i.stack.imgur.com/8B819.png
I found a solution here: aggregate(.~Agentdepartment, df, function(x) paste0(unique(x), collapse = "/"), na.action = na.pass). But it is aggregating Null values too.
Can anyone please suggest.