0

I want to make a loop that can modify a column which contains a string with just a part of that string. For instance, a row could contain this person crossed at point a or the human came inside point a, and I would like to replace those with just "a" without the extra commentary.

lbevs
  • 11
  • 1
  • 3
  • Use `grepl` or `stringr::str_detect`... or perhaps `gsub` or `stringr::str_replace`. If you need more help than that, please post a small reproducible example with sample input and desired output. For additional guidance, you might want to see the Help Center's [How to create a good example ?](https://stackoverflow.com/help/minimal-reproducible-example) or the R-specific FAQ for making [Reproducible examples in R](https://stackoverflow.com/q/5963269/903061). – Gregor Thomas May 04 '20 at 20:19
  • 1
    Sharing data with `dput` is easy on everyone because it preserves the structure of you data in a copy/pasteable way, e.g., `dput(your_data[1:10, 2:3])` for the first 10 rows and columns 2 and 3. – Gregor Thomas May 04 '20 at 20:19

0 Answers0