Reputation: 3
I have a big dataframe and a list of value (character). I want to subset the dataframe based on one column which contains value in the list. What should I do?
Thanks Leilei
Upvotes: 0
Views: 146
Reputation: 349
I assume you want something like this.. Please make a reproducable example next time ://
data.frame(letters = c("a", "b", "c", "d"), value = 1:4) -> df
list("a", "y", "b", "x") -> subset_list
df[df$letters %in% subset_list,] -> df_subset
Upvotes: 1