Re: [R] toupper does not work in sub + regex

2009-04-13 Thread William Dunlap
> From: Tan, Richard [mailto:r...@panagora.com] > Sent: Monday, April 13, 2009 10:23 AM > To: William Dunlap > Cc: r-help@r-project.org > Subject: RE: [R] toupper does not work in sub + regex > > Thanks, Bill! One more question, how do I get SviRaw, i.e., just > upperca

Re: [R] toupper does not work in sub + regex

2009-04-13 Thread Tan, Richard
m: William Dunlap [mailto:wdun...@tibco.com] Sent: Monday, April 13, 2009 1:17 PM To: Tan, Richard; r-help@r-project.org Subject: Re: [R] toupper does not work in sub + regex You could also use \\U and \\L in the replacement with perl=TRUE. \\U "converts the rest of the replacement to upper case&

Re: [R] toupper does not work in sub + regex

2009-04-13 Thread William Dunlap
t; > sub("q_([a-z])([a-zA-Z]*)", "\\U\\1 then \\2", "q_sviRaw", perl=TRUE) [1] "S then VIRAW" Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap tibco.com -- [R] toupper does not wor

Re: [R] toupper does not work in sub + regex

2009-04-13 Thread Gabor Grothendieck
sub only handles replacement strings, not replacement functions. Your code is the same as: sub("q_([a-z])[a-zA-Z]*", '\\1', "q_sviRaw") since toupper('\\1') has no alphabetics so its just literally '\\1' and the latter is what sub uses. The gsubfn function in the gsubfn package can deal with rep

Re: [R] toupper does not work in sub + regex

2009-04-13 Thread Tan, Richard
Thanks, Martin. I did not realize that. I never used perl compatible regex before but seems now I should! Richard -Original Message- From: Martin Morgan [mailto:mtmor...@fhcrc.org] Sent: Monday, April 13, 2009 12:08 PM To: Tan, Richard Subject: Re: [R] toupper does not work in sub

[R] toupper does not work in sub + regex

2009-04-13 Thread Tan, Richard
Hi, I don't know what I am doing wrong to the toupper does not seem working in sub + regex. The following returns 's' not the upper class 'S' as I expect: sub("q_([a-z])[a-zA-Z]*",toupper('\\1'),"q_sviRaw") Can someone tell me where I did wrong? Thanks, Richard [[alternative HTML ve