1

If I have the following dataframe:

Fruits
ONE_APPLE
TWO_BANANAS
THREE_ORANGES
FOUR_PINAPPLES

Is it possible to delete everything before the underscore, getting as a result:

Fruits
APPLE
BANANAS
ORANGES
PINAPPLES

There may be a pattern matching function but I haven't find the right one.

Thanks for your support.

oguz ismail
  • 1
  • 16
  • 47
  • 69
rwn1v
  • 777
  • 3
  • 10
  • 23

1 Answers1

8

You could try the below gsub command to remove all the characters before _(including the symbol _)

gsub(".*_", "", Test)
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274