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 for the

Re: [R] regex challenge

2013-08-16 Thread William 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 Sent: Thursday, August 15, 2013 7:47 PM To: RHELP Subject: Re: [R] regex challenge Bill that is very impresive

Re: [R] regex challenge

2013-08-16 Thread Frank Harrell
PM To: RHELP Subject: Re: [R] regex challenge Bill that is very impresive. The only problem I'm having is that I want the paste0(toupper(...)) to be a general function that returns a character string that is a legal part of a formula object that can't be converted to a 'name'. Frank

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: Wednesday, August 14, 2013 8:14 PM To: RHELP Subject: [R] regex challenge I would like to be able to use gsub or gsubfn to process a formula and to translate the variables but to ignore expressions

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

Re: [R] regex challenge

2013-08-15 Thread arun
To: Frank Harrell f.harr...@vanderbilt.edu Cc: RHELP r-h...@stat.math.ethz.ch 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( ([a-zA-Z][a-zA-Z0-9]*)((?=\\s

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 Duncan

Re: [R] regex challenge

2013-08-15 Thread William Dunlap
] regex challenge 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

Re: [R] regex challenge

2013-08-15 Thread William Dunlap
wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap Sent: Thursday, August 15, 2013 6:03 PM To: Frank Harrell; RHELP Subject: Re: [R] regex challenge Try this one ff - function (expr

Re: [R] regex challenge

2013-08-15 Thread Frank Harrell
-Original Message- From: [hidden email] [mailto:[hidden email]] On Behalf Of William Dunlap Sent: Thursday, August 15, 2013 6:03 PM To: Frank Harrell; RHELP Subject: Re: [R] regex challenge Try this one ff - function (expr) { if (is.call(expr) is.name(expr[[1

[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

Re: [R] regex challenge

2013-08-14 Thread Guanrao Chen
14, 2013 11:13 PM Subject: [R] regex challenge 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