I have a dataset with two columns source
and id
. I want to check which of the ids in the id
column are present in both categories of the column source
.
Here is an example:
dd <- read.table(text="
source id
a 1
a 2
a 3
b 1
b 3
b 4",
header=TRUE, stringsAsFactors=FALSE)
For this example i want to get the ids 1 and 3 because they occur in both categories.
Is there a way to retrieve all the ids with e.g. dplyr?