Re: [R] gsub issue with consecutive pattern finds

2024-03-01 Thread Bert Gunter
Oh, wait a second. I misread your original post. Please ignore my truly incorrect suggestion. -- Bert On Fri, Mar 1, 2024 at 7:57 AM Bert Gunter wrote: > > Here's another *incorrect* way to do it -- incorrect because it will > not always work, unlike Iris's correct solution. But it does not >

Re: [R] gsub issue with consecutive pattern finds

2024-03-01 Thread Bert Gunter
Here's another *incorrect* way to do it -- incorrect because it will not always work, unlike Iris's correct solution. But it does not require PERL type matching. The idea: separate the two vowels in the regex by a character that you know cannot appear (if there is such) and match it optionally,

Re: [R] gsub issue with consecutive pattern finds

2024-03-01 Thread Iago Giné Vázquez
Hi Iris, Thank you. Further, very nice solution. Best, Iago On 01/03/2024 12:49, Iris Simmons wrote: > Hi Iago, > > > This is not a bug. It is expected. Patterns may not overlap. However, there > is a way to get the result you want using perl: > > ```R > gsub("([aeiouAEIOU])(?=[aeiouAEIOU])",

Re: [R] gsub issue with consecutive pattern finds

2024-03-01 Thread Iris Simmons
Hi Iago, This is not a bug. It is expected. Patterns may not overlap. However, there is a way to get the result you want using perl: ```R gsub("([aeiouAEIOU])(?=[aeiouAEIOU])", "\\1_", "aerioue", perl = TRUE) ``` The specific change I made is called a positive lookahead, you can read more

[R] gsub issue with consecutive pattern finds

2024-03-01 Thread Iago Giné Vázquez
Hi all, I tested next command: gsub("([aeiouAEIOU])([aeiouAEIOU])", "\\1_\\2", "aerioue") with the following output: [1] "a_eri_ou_e" So, there are two consecutive vowels where an underscore is not added. May it be a bug? Is it expected (bug or not)? Is there any chance to get what I want

[R] gsub() issue...

2011-05-17 Thread Thibault Charles
Hello R helpers, I get a problem using gsub() function. I have the following text : text - ‘’ INFILTRATION INF_BASE AIRCHANGE=1 ‘’ Then my code is : original - INFILTRATION INF_BASE \n AIRCHANGE=1 replace - INFILTRATION INF_BASE \n AIRCHANGE=3 new_texte -

Re: [R] gsub() issue...

2011-05-17 Thread Sebastian Gibb
Hello Thibault Charles, I have the following text : text - ‘’ INFILTRATION INF_BASE AIRCHANGE=1 ‘’ becomes: text - INFILTRATION INF_BASE\nAIRCHANGE=1 original - INFILTRATION INF_BASE \n AIRCHANGE=1 There are spaces around \n. That's why text != original Try original - INFILTRATION

Re: [R] gsub() issue...

2011-05-17 Thread Thibault Charles
 : mardi 17 mai 2011 11:15 À : r-help@r-project.org Objet : Re: [R] gsub() issue... Hello Thibault Charles, I have the following text : text - ‘’ INFILTRATION INF_BASE AIRCHANGE=1 ‘’ becomes: text - INFILTRATION INF_BASE\nAIRCHANGE=1 original - INFILTRATION INF_BASE \n AIRCHANGE=1

Re: [R] gsub() issue...

2011-05-17 Thread David Winsemius
The backslashes in the patt argument need to be doubled since \ is a special regex character. Or it may work to set fixed =TRUE. Either: original - INFILTRATION INF_BASE \\n AIRCHANGE=1 replace - INFILTRATION INF_BASE \n AIRCHANGE=3 new_texte - gsub(patt=original,replace,text) Or:

Re: [R] gsub() issue...

2011-05-17 Thread Andrew Robinson
Hi Charles, It's not clear to me what you mean by doesn't work. test - Interesting 1\nPoint\n cat(test) Interesting 1 Point test1 - gsub(ing 1\nP,ing 3\nP, test) cat(test1) Interesting 3 Point Cheers Andrew On Tue, May 17, 2011 at 10:45:31AM +0200, Thibault Charles wrote: Hello R

[R] gsub issue in R 2.11.1, but not present in 2.9.2

2010-06-29 Thread Jason Rupert
Previously in R 2.9.2 I used the following to convert from an improperly formatted NA string into one that is a bit more consistent. gsub(N\A, NA, N\A, fixed=TRUE) This worked in R 2.9.2, but now in R 2.11.1 it doesn't seem to work an throws the following error. Error: '\A' is an

Re: [R] gsub issue in R 2.11.1, but not present in 2.9.2

2010-06-29 Thread Duncan Murdoch
On 29/06/2010 6:47 AM, Jason Rupert wrote: Previously in R 2.9.2 I used the following to convert from an improperly formatted NA string into one that is a bit more consistent. gsub(N\A, NA, N\A, fixed=TRUE) This worked in R 2.9.2, but now in R 2.11.1 it doesn't seem to work an throws the

Re: [R] gsub issue in R 2.11.1, but not present in 2.9.2

2010-06-29 Thread Uwe Ligges
On 29.06.2010 12:47, Jason Rupert wrote: Previously in R 2.9.2 I used the following to convert from an improperly formatted NA string into one that is a bit more consistent. gsub(N\A, NA, N\A, fixed=TRUE) This worked in R 2.9.2, but now in R 2.11.1 it doesn't seem to work an throws the

Re: [R] gsub issue in R 2.11.1, but not present in 2.9.2

2010-06-29 Thread Bert Gunter
Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Uwe Ligges Sent: Tuesday, June 29, 2010 4:11 AM To: Jason Rupert Cc: r-help@r-project.org Subject: Re: [R] gsub issue in R 2.11.1, but not present

Re: [R] gsub issue in R 2.11.1, but not present in 2.9.2

2010-06-29 Thread Bert Gunter
[mailto:r-help-boun...@r-project.org] On Behalf Of Uwe Ligges Sent: Tuesday, June 29, 2010 4:11 AM To: Jason Rupert Cc: r-help@r-project.org Subject: Re: [R] gsub issue in R 2.11.1, but not present in 2.9.2 On 29.06.2010 12:47, Jason Rupert wrote: Previously in R 2.9.2 I used the following

Re: [R] gsub issue in R 2.11.1, but not present in 2.9.2

2010-06-29 Thread Nordlund, Dan (DSHS/RDA)
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Bert Gunter Sent: Tuesday, June 29, 2010 11:08 AM To: 'Jason Rupert'; 'Duncan Murdoch' Cc: r-help@r-project.org Subject: Re: [R] gsub issue in R 2.11.1, but not present in 2.9.2

Re: [R] gsub issue in R 2.11.1, but not present in 2.9.2

2010-06-29 Thread Uwe Ligges
Subject: Re: [R] gsub issue in R 2.11.1, but not present in 2.9.2 On 29.06.2010 12:47, Jason Rupert wrote: Previously in R 2.9.2 I used the following to convert from an improperly formatted NA string into one that is a bit more consistent. gsub(N\A, NA, N\A, fixed=TRUE) This worked in R