Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 204771

Delete string pattern in R while keeping the rest of the string

$
0
0

I know this has been asked previously, but I'm unable to find an case that is comparable to the situation in my data. Here's a sample of my data:

> head(dataraw)
   success                       2 day pre during      time observator
1:      no dry, but with some snow showers    dry 2/23/2015     JvD&OK
2:  yes001 dry, but with some snow showers    dry 2/23/2015     JvD&OK
3:  yes004 dry, but with some snow showers    dry 2/23/2015     JvD&OK
4:  yes004 dry, but with some snow showers    dry 2/23/2015     JvD&OK
5:      no dry, but with some snow showers    dry 2/23/2015     JvD&OK
6:      no dry, but with some snow showers    dry 2/23/2015     JvD&OK

In column success, I would like to remove all numbers after "yes". I've though using the following line would work, but it doesn't:

dataraw$success <- gsub('0**', '', dataraw$success)

Could somebody please set me on the right track?


Viewing all articles
Browse latest Browse all 204771

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>