0

I have a Data set with many columns and rows, in am narrowing down the data as to get a specific answer. I want to remove all occurances of Names within a column. i know you can do this for columns that are Numbers, buy removing number below or over a certain number

for example: data =

ID Name sport

  1. ted football
  2. tom football
  3. tim hockey
  4. tod Track
  5. ben football

for numbers i would

removen <- data[data$ID < 2, ]

removen =

ID Name Sport

  1. tim hockey
  2. tod Track
  3. ben football

i want to assign

x <- c(all occurances of football)

so when i call x i would get

ID Name sport

  1. ted football
  2. tom football
  3. ben football

Thank you in advance and sorry for the formating.

1 Answers1

0

You can use grepl

x <- subset(df, grepl('football', sport))
x

  ID Name    sport
1  1  ted football
2  2  tom football
5  5  ben football
Onyambu
  • 67,392
  • 3
  • 24
  • 53