I would like to get explanation on the R's dplyr filter behavior below:
df <- data.frame( x = rep('test',3), y = c('service','audio','video') )
filter(df , y == 'service')
#result 1
x y
test service
filter(df , 'service' %in% y)
#result 2
x y
test service
test audio
test video
Can I get explanation on above behavior? I want to filter out the word service in column 'y'. I do not understand why the row with 'audio' and 'video' get filtered too.
EDIT: I do not understand why I am being flagged down for having this question. I am aware of the difference between '==' and '%in%'. I do not ask the difference between '==' and '%in%' in general. I am wondering why my code does not give the wanted output when using %in% IN dplyr's filter. I am not using %in% randomly and then asking why it behaves that way afterward. Again I am aware of what %in% does. Please see through my question instead of seeing the header only.
EDIT2: As per suggestion, I am changing my header to indicate that my question is different from existing question with similar header.