I have a data frame with an ID column and a few columns for values. I would like to only keep certain rows of the data frame based on whether or not the value of ID at that
Try df[df$ID %in% keep, ] or subset(df, ID %in% keep) -- see the help page for sets.
df[df$ID %in% keep, ]
subset(df, ID %in% keep)
Edit: Also, if this were for a single letter, you could write e.g. df[df$ID == "a", ] instead of using which().
df[df$ID == "a", ]
which()