Eliminate characters before a pattern in R [duplicate]

瘦欲@ 提交于 2021-01-28 13:38:02

问题


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.


回答1:


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

gsub(".*_", "", Test)


来源:https://stackoverflow.com/questions/24400094/eliminate-characters-before-a-pattern-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!