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
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
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
-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
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
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
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
] 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
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
-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
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
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
12 matches
Mail list logo