This might be quite simple but it's been bugging me for a while. I lack the terminology for this type of indexing/conditional check - so it was hard for me to look it up.
Have a data frame dat.
X1 X2 X3
1 1 2
1 1 3
3 1 2
dat == 1 gives me:
X1 X2 X3
TRUE TRUE FALSE
TRUE TRUE FALSE
FALSE TRUE FALSE
dat == 1 | dat == 3 gives me:
X1 X2 X3
TRUE TRUE FALSE
TRUE TRUE TRUE
TRUE TRUE FALSE
However, dat %in% c(1,3) gives me a single line vector back, and doesn't work "as intended". How can I get it to work on a vector without some fancy loop?
Thank you in advance.