I have a data frame that looks like this:
id dob lname
1 1900-01-01 a
2 1900-01-01 b
3 1900-01-01 b
4 1901-01-01 c
5 1901-01-01 d
6 1902-01-01 e
7 1902-01-01 e
8 1902-01-01 f
9 1903-01-01 g
10 1903-01-01 h
I want to filter to show all rows where dob
is duplicated AND lname
is duplicated, so the desired output would look like this:
id dob lname
2 1900-01-01 b
3 1900-01-01 b
6 1902-01-01 e
7 1902-01-01 e
I tried grouping by both dob and lname, but I'm stuck on the next step, which would return all rows where those columns have duplicate values.
Here is code for the example:
id <- c(1:10)
dob <- date(c("1900-01-01", "1900-01-01", "1900-01-01", "1901-01-01", "1901-01-01", "1902-01-01", "1902-01-01", "1902-01-01", "1903-01-01", "1903-01-01"))
lname <- c("a", "b", "b", "c", "d", "e", "e", "f", "g", "h")
df <- data.frame("id" = id, "dob" = dob, "lname" = lname)