Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201945

Check for occurence in both categories

$
0
0

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?


Viewing all articles
Browse latest Browse all 201945

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>