Skip to content

Instantly share code, notes, and snippets.

@cgpu
Last active May 11, 2019 13:26
Show Gist options
  • Select an option

  • Save cgpu/5f2d3be7986e683a52e66313724e3f65 to your computer and use it in GitHub Desktop.

Select an option

Save cgpu/5f2d3be7986e683a52e66313724e3f65 to your computer and use it in GitHub Desktop.
Select rows from a dataframe based on a list of values contained in column of choice.
names_to_keep <- c('item1', 'item2', 'etc')
df_sliced <- df[is.element(df$name , names_to_keep ), ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment