I\'d like to subset a dataframe to include only rows that have unique combinations of three columns. My situation is similar to the one presented in this question, but I\'d
You can use the plyr package:
plyr
library(plyr) ddply(df, c("v1","v2","v3"), head, 1) # v1 v2 v3 v4 v5 # 1 7 1 A 100 98 # 2 7 2 A 98 97 # 3 8 1 C NA 80 # 4 9 3 C 75 75 ddply(df, c("v1","v2","v3"), function(x) if(nrow(x)>1) x else NULL) # v1 v2 v3 v4 v5 # 1 8 1 C NA 80 # 2 8 1 C 78 75 # 3 8 1 C 50 62