Re: [R] regex challenge

2013-08-17 Thread Frank Harrell
Bill I found a workaround: f <- ff(formula, lab) f <- as.formula(gsub("`", "", as.character(deparse(f Thanks for your elegant solution. Frank -- Thanks Bill. The problem is one of the results of convertName might be 'Heading("Age in Years")*age' (this is fo

Re: [R] regex challenge

2013-08-16 Thread Frank Harrell
re, TIBCO Software wdunlap tibco.com > -Original Message----- > From: [hidden email] [mailto:[hidden email]] On Behalf > Of Frank Harrell > Sent: Thursday, August 15, 2013 7:47 PM > To: RHELP > Subject: Re: [R] regex challenge > > Bill that is very impresive. The only

Re: [R] regex challenge

2013-08-16 Thread William Dunlap
r[[i]], convertName = convertName) } } else if (is.name(expr)) { expr <- as.name(convertName(expr)) } expr } Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project

Re: [R] regex challenge

2013-08-15 Thread Frank Harrell
quot;Female") * SBPz) * Heading() * Gz + (AGEz + SBPz) * Heading() * TRIOz ~ Heading() * COUNTRYz * Heading() * SEXz Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: [hidden email] [mailto:[hidden email]] On Behalf > Of William Dunlap &

Re: [R] regex challenge

2013-08-15 Thread William Dunlap
"Female") * SBPz) * Heading() * Gz + (AGEz + SBPz) * Heading() * TRIOz ~ Heading() * COUNTRYz * Heading() * SEXz Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] O

Re: [R] regex challenge

2013-08-15 Thread William Dunlap
-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Frank Harrell > Sent: Thursday, August 15, 2013 4:45 PM > To: RHELP > Subject: Re: [R] regex challenge > > I really appreciate the excellent ideas from Bill Dunlap and Greg Snow. > Both sugg

Re: [R] regex challenge

2013-08-15 Thread Frank Harrell
I really appreciate the excellent ideas from Bill Dunlap and Greg Snow. Both suggestions almost work perfectly. Greg's recognizes expressions such as sex=='female' but not ones such as age > 21, age < 21, a - b > 0, and possibly other legal R expressions. Bill's idea is similar to what Dunca

Re: [R] regex challenge

2013-08-15 Thread arun
- From: Greg Snow <538...@gmail.com> To: Frank Harrell Cc: RHELP Sent: Thursday, August 15, 2013 5:07 PM Subject: Re: [R] regex challenge Here is a first stab: library(gsubfn) test <- "y1 + y2 ~ a*(b + c) + d + f * (h == 3) + (sex == 'male')*i" gsubfn( &q

Re: [R] regex challenge

2013-08-15 Thread Greg Snow
Here is a first stab: library(gsubfn) test <- "y1 + y2 ~ a*(b + c) + d + f * (h == 3) + (sex == 'male')*i" gsubfn( "([a-zA-Z][a-zA-Z0-9]*)((?=\\s*[-+~)*])|\\s*$)", function(x,...) paste0(toupper(x),'z'), test, perl=TRUE ) On Wed, Aug 14, 2013 at 9:13 PM, Frank Harrell wrote: > I would like t

Re: [R] regex challenge

2013-08-15 Thread William Dunlap
ula(do.call("substitute", list(formula, newVars)), env=environment(formula)) } Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Frank Harrell >

Re: [R] regex challenge

2013-08-14 Thread Guanrao Chen
This might be hard. How to tell f is to be changed while h is NOT ...   Thanks, Guanrao http://www.myfav5.com where fun and easy friend-making happens From: Frank Harrell To: RHELP Sent: Wednesday, August 14, 2013 11:13 PM Subject: [R] regex challenge

[R] regex challenge

2013-08-14 Thread Frank Harrell
I would like to be able to use gsub or gsubfn to process a formula and to translate the variables but to ignore expressions in the formula. Supposing that the R formula has already been transformed into a character string and that the transformation is to convert variable names to upper case an