Question: Having a dataframe like this

```
df <- data.frame(ID = sample(rep(letters, each=3)), value = rnorm(n=26*3))
keep <- c("a", "d", "r", "x")

```

How is it possible to keep both "a" and "d"

example using something like this: `df[df$ID == "a"|"d", ]`

Answer: 
Use `%in%` 

```r
df[df$ID %in% c("a","d"), ]

```
We can use base R function `which()`. `which()` returns indexes where given condition is met.

```
df[which(df$ID == "a" | df$ID == "d"),]

```