Skip to content

Instantly share code, notes, and snippets.

@noahhl
Created January 26, 2012 14:25
Show Gist options
  • Select an option

  • Save noahhl/1683007 to your computer and use it in GitHub Desktop.

Select an option

Save noahhl/1683007 to your computer and use it in GitHub Desktop.
> data <- data.frame(a = c(1,2,3,4,4,5), b = c('a', 'b', 'c', 'd', 'e', 'f'))
> data[!duplicated(data$a), ]
a b
1 1 a
2 2 b
3 3 c
4 4 d
6 5 f
> data[!duplicated(data$a) & !duplicated(data$a, fromLast=T), ]
a b
1 1 a
2 2 b
3 3 c
6 5 f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment