Keeping only certain rows of a data frame based on a set of values

后端 未结 1 1831
梦如初夏
梦如初夏 2020-12-03 17:53

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

相关标签:
1条回答
  • 2020-12-03 18:27

    Try df[df$ID %in% keep, ] or subset(df, ID %in% keep) -- see the help page for sets.

    Edit: Also, if this were for a single letter, you could write e.g. df[df$ID == "a", ] instead of using which().

    0 讨论(0)
提交回复
热议问题