...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Bert Gunter
> Sent: Friday, August 20, 2010 2:55 PM
> To: r-help@r-project.org
> Subject: [R] Regex exercise
>
> For regular expression afficianados, I'd like a cleverer solution to
> the following pro
> You are essentially doing the eval and parsing by hand instead of
> letting eval(parse()) do the work. I prefer the latter.
Hi, Bert. Yes, I agree with both your analysis and your preference.
> However, your code did something that I did not expect and for which I
> can find no documentation -
Thanks Michael:
You are essentially doing the eval and parsing by hand instead of
letting eval(parse()) do the work. I prefer the latter.
However, your code did something that I did not expect and for which I
can find no documentation -- I would have thought it shouldn't work.
... and that is, t
> For regular expression afficianados, I'd like a cleverer solution to
> the following problem (my solution works just fine for my needs; I'm
> just trying to improve my regex skills):
>
> Given the string (entered, say, at a readline prompt):
>
> "1 2 -5, 3- 6 4 8 5-7 10" ## only integers wil
On Aug 20, 2010, at 4:16 PM, RICHARD M. HEIBERGER wrote:
> Bert,
>
> we can save a lot of time by using paste and then only one call to eval and
> parse.
>
>> x2 <- c("1","2:5", "3:6", "4","8","5:7", "10")
>> system.time(for (i in 1:100) unlist(lapply(parse(text=x2),eval)))
> u
On Fri, 20 Aug 2010, Bert Gunter wrote:
Given the string (entered, say, at a readline prompt):
"1 2 -5, 3- 6 4 8 5-7 10" ## only integers will be entered
Presumably only non-negative integers
(Special note to Thomas Lumley: This seems one of the few instances
where eval(parse..)) may a
Bert,
we can save a lot of time by using paste and then only one call to eval and
parse.
> x2 <- c("1","2:5", "3:6", "4","8","5:7", "10")
> system.time(for (i in 1:100) unlist(lapply(parse(text=x2),eval)))
user system elapsed
0.060.000.03
> system.time(for (i in 1:10
For regular expression afficianados, I'd like a cleverer solution to
the following problem (my solution works just fine for my needs; I'm
just trying to improve my regex skills):
Given the string (entered, say, at a readline prompt):
"1 2 -5, 3- 6 4 8 5-7 10" ## only integers will be entere
8 matches
Mail list logo