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, 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
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
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
&
"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
-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
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
-
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
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
I think substitute() or bquote() will do a better job here than gsub() be
they work on the parsed formula rather than on the raw string. The
terms() function will interpret the formula-specific operators like "+"
and ":" to come up with a list of the 'variables' (or 'terms') in the formula
E.g.,
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
I
11 matches
Mail list logo