Re: [R] Help with gsub function

2019-03-18 Thread Bill Poling
Good morning Steve. Terrific, so kind of you to follow-up. I will add that to my ever growing R bag of tips and tricks. Cheers. WHP William H. Poling, Ph.D., MPH | Manager, Revenue Development Data Intelligence & Analytics Zelis Healthcare -Original Message- From: S Ellison Sent:

Re: [R] Help with gsub function

2019-03-18 Thread S Ellison
> tb2a$TID2 <- gsub(tb2a$TID, pattern="-[0-0]{0,7}", replacement = "") Just to add something on why this didn't work ... It looks like you were trying to match a hyphen followed by a number up to seven digits. by mistake(?) you gave the digit range as [0-0] so it would repmatch a hyphen

Re: [R] Help with gsub function

2019-03-17 Thread Bill Poling
Yep, thank you Jeff, consequence of the first url I landed on asking how to do it and rushing off. All set now. Appreciate your help. WHP From: Jeff Newmiller Sent: Friday, March 15, 2019 4:00 PM To: r-help@r-project.org; Bill Poling ; r-help (r-help@r-project.org) Subject: Re: [R] Help

Re: [R] Help with gsub function

2019-03-16 Thread Bill Poling
) Subject: Re: [R] Help with gsub function If you want to remove just the hyphen, why not do sub("-", "", tb2a$TID) sub("-", "", "73-017323") [1] "73017323" Am I missing something? Peter On Fri, Mar 15, 2019 at 12:46 PM Bill Poli

Re: [R] Help with gsub function

2019-03-15 Thread Jeff Newmiller
Your pattern seems ... way overboard? Why not gsub("-", "", tb2a$TID) On March 15, 2019 12:45:27 PM PDT, Bill Poling wrote: >Good afternoon. > >sessionInfo() >#R version 3.5.3 (2019-03-11) >#Platform: x86_64-w64-mingw32/x64 (64-bit) >#Running under: Windows >= 8 x64 (build 9200) > >I am using

Re: [R] Help with gsub function

2019-03-15 Thread Peter Langfelder
If you want to remove just the hyphen, why not do sub("-", "", tb2a$TID) sub("-", "", "73-017323") [1] "73017323" Am I missing something? Peter On Fri, Mar 15, 2019 at 12:46 PM Bill Poling wrote: > > Good afternoon. > > sessionInfo() > #R version 3.5.3 (2019-03-11) > #Platform:

Re: [R] Help with gsub function

2019-03-15 Thread Ivan Krylov
On Fri, 15 Mar 2019 19:45:27 + Bill Poling wrote: Hello Bill, > tb2a$TID2 <- gsub(tb2a$TID, pattern="-[0-0]{0,7}", replacement = "") Is the pattern supposed to mean something besides the "-" you want to remove? For the problem you describe, pattern="-" should be enough. It should locate

[R] Help with gsub function

2019-03-15 Thread Bill Poling
Good afternoon. sessionInfo() #R version 3.5.3 (2019-03-11) #Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows >= 8 x64 (build 9200) I am using gsub function to remove a hyphen in a 9 character column of values in order to convert it to integer. Works fine except where the

Re: [R] Help with gsub function or a similar function

2012-04-06 Thread Sarah Goslee
You don't provide a reproducible example, or even str(), but I'd guess you need to match ^15 instead of just 15. Sarah On Apr 5, 2012, at 10:38 PM, ieatnapalm era...@tulane.edu wrote: Hey, sorry if this has been addressed before, but I'm really new to R and having trouble with the gsub

[R] Help with gsub function or a similar function

2012-04-05 Thread ieatnapalm
Hey, sorry if this has been addressed before, but I'm really new to R and having trouble with the gsub function. I need a way to make this function exclude certain values from being substituted: ie my data looks something like (15:.0234,10:.0157) and I'm trying to replace the leading 15 with

Re: [R] Help with gsub function or a similar function

2012-04-05 Thread David Winsemius
On Apr 5, 2012, at 10:38 PM, ieatnapalm wrote: Hey, sorry if this has been addressed before, but I'm really new to R and having trouble with the gsub function. I need a way to make this function exclude certain values from being substituted: ie my data looks something like