2

In a column within my dataframe, I would like to replace any level that contains the word "tech" in it (fintech, fin tech, agtech, tech, etc) with "technology". How can I do this with gsub?

I'd also like any string with the word "online" or "marketplace" in it to be replaced with "consumer internet"

sjoelly
  • 147
  • 2
  • 11
  • 2
    The first one is just a straight subset and replace - `df$col[grepl("tech",df$col)] <- "technology"` as per previous questions like: https://stackoverflow.com/questions/13275614/replace-entire-expression-that-contains-a-specific-string - which also covers the second multiple string logic combining with `|` as well. `df$col[grepl("online|marketplace",df$col)] <- "consumer internet"` – thelatemail Apr 30 '20 at 23:02
  • very helpful, thank you! – sjoelly Apr 30 '20 at 23:20

0 Answers0