Remove Duplicate Rows

Want to learn more? I recommend working through: R for Data Science, R Cookbook, and R Graphics Cookbook.

# create a dataframe with simulated values
x <- c(1,2,3,1,2,2)
y <- c(1,6,3,1,2,2)
z <- c(1,2,3,1,2,2)
a <- c(1,5,6,1,2,2)
data <- data.frame(x, y, z, a)
rm(x, y, z, a)
# find all the rows that are the same
duplicates <- data[duplicated(data),];duplicates
  x y z a
4 1 1 1 1
6 2 2 2 2
# find all the rows that are unique
not.duplicates <- unique(data);not.duplicates
  x y z a
1 1 1 1 1
2 2 6 2 5
3 3 3 3 6
5 2 2 2 2