I want to separate a dataset into 2, one contains duplicated rows and another one contains unique rows. One dataset only has unique rows if using distinct(id,.keep_all=T) , but lost duplicated rows. How generate 2 sets and keep both rows? Thanks in advance!
employee <- c('John','Peter','Jolie','Hot')
salary <- c(21000, 23400, 26800, 23000)
id <- c(1,2,3,1)
data <- data.frame(employee, salary, id, stringsAsFactors=FALSE)
How about grouping by all columns (assuming your definition of duplicate is when all columns same)
Unique will be row number 1 within each group. Duplicates are rows > 1