I am looking to remove duplicates from my code with the distinct()
function, however I don't want it to remove some duplicates based on an additional condition.
For example, my data frame has variables of position
, place
, company
, and source
, so I want the rows of duplicates only to be removed when position
, place
, and company
are the same, and while the source
variable is different. This is the function I am using.
omit <- distinct(final, position, place, company, .keep_all = TRUE)
I just want the duplicates to be removed when they are matching for three variables, while remaining different for the other one. Is there some other way this could be done?