Last active
December 8, 2016 21:36
-
-
Save fmichonneau/511913355ac56db148e2f924f97df0c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Resolving this: http://stackoverflow.com/questions/32035865/r-remove-rows-from-a-data-frame-that-contain-a-duplicate-of-either-combination-o | |
# using dplyr | |
Var1 <- c(1,2,3,4,5,5) | |
Var2 <- c(4,3,2,1,5,5) | |
f <- c("blue","green","yellow","red","orange2","grey") | |
g <- c("blue","green","yellow","red","orange1","grey") | |
testdata <- data.frame(Var1,Var2,f,g) | |
library(dplyr) | |
testdata %>% | |
rowwise() %>% | |
mutate(key = paste(sort(c(Var1, Var2)), collapse="")) %>% | |
distinct(key, .keep_all=T) %>% | |
select(-key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment