'Get unique values in two columns at the same time (not unique combination)
I have a data frame like this:
dat <- data.frame(x1 = c(1,2,2,3,3,4,5), x2 = c("a","a","b","c","d","e","e")).
My desired output is to keep the rows that have unique values in column X1 and also have unique values in column X2 at the same time AND keep as many unique values in column x1 as possible. For example, the desired output could be data.frame(x1=c(1,2,3,4), x2=c("a","b","c","e")) or data.frame(x1=c(1,2,3,5), x2=c("a","b","c","e")). I'm okay with any one of these two outputs.
Hope to get your advice. Thanks a lot.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
