i have two message ids say 197, 198 . I want to subset the data frame for those users who have got the messages from these ids. I only want those rows which contains both these message ids.
The data frame is m
I have used the code
a = c(197,198)
n = subset(m$userid,m$mid %in% a)
I also tried
n = m[m$mid == 197 & m$mid == 198]
both of these codes are creating OR output whereas I want AND output.
here is the sample dataframe:
mid userid opened
197 1022 Y
197 1036 N
197 1100 Y
198 1000 Y
198 1022 N
198 1036 Y
I want output as records containing userid for both mid 197 &198
mid userid opened
197 1022 Y
197 1036 N
198 1022 N
198 1036 Y