Find and replace entire value in R

前端 未结 4 976
青春惊慌失措
青春惊慌失措 2021-01-24 04:29

I\'m looking for a way to use the find and replace function in R to replace the entire value of a string, rather than just the matching part of the string. I have a dataset with

4条回答
  •  庸人自扰
    2021-01-24 05:12

    You can also simply use gsub() and add .* before and after the pattern like this:

    string<-"TransRights"
    gsub(".*sR.*","HumanRights",string)
    

    The outcome would be

    HumanRights
    

提交回复
热议问题