I just want to duplicate the records that are based on >1 column using dplyr / tidyverse
Example
library(dplyr)
df <- data.frame(a=c(1,1,1,2,2,2), b=c(1,2,1,2,1,2), stringsAsFactors = F)
I thought the above command would return rows 3 and 6, but it returns 0 rows.
df %>% filter(duplicated(a, b))
# [1] a b
# <0 rows> (or 0-length row.names)
Conversely, I thought this would return rows 1,2,4 and 5, but it returns all rows.
df %>% filter(!duplicated(a, b))
# a b
# 1 1 1
# 2 1 2
# 3 1 1
# 4 2 2
# 5 2 1
# 6 2 2
Am I missing something?