t;"
>>> [5] " "
>>> [6] " 1.3770E-03 3.4644E-07"
>>> [7] " 1.9412E-04 4.8840E-08"
>>>
>>> ## Now it can be scanned to a numeric via
>>>
>>>
] " 1.9412E-04 4.8840E-08"
>>
>> ## Now it can be scanned to a numeric via
>>
>>> z<-scan(textConnection(z),what=0)
>> Read 8 items
>>> z
>> [1] 1.3770e-03 3.4644e-07 1.9412e-04 4.8840e-08 1.3770e-03 3.4644e-07
>>
general, but I haven't checked it
> carefully and would appreciate folks pointing out where it trips up (e.g.
> perhaps with NA's).
>
> Best,
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> -Original Message-
> From: r-help-boun...@r-project.org
s reasonably general, but I haven't checked it
> carefully and would appreciate folks pointing out where it trips up (e.g.
> perhaps with NA's).
>
> Best,
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> -Original Message-
> From: r-help-boun
inical Biostatistics
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of baptiste auguie
Sent: Wednesday, November 18, 2009 3:57 AM
To: r-help
Subject: [R] parsing numeric values
Dear list,
I'm seeking advice to extract some num
Thanks. This is now fixed in the development version so that it gives
an error rather than crashing:
> library(gsubfn)
Loading required package: proto
Loading required package: tcltk
Loading Tcl/Tk interface ... done
> source("http://gsubfn.googlecode.com/svn/trunk/R/gsubfn.R";)
> strapply("test",
Thanks a lot, both of you.
Incidentally, I made R crash when I forgot the X argument to strapply,
library(gsubfn)
Loading required package: tcltk
Loading Tcl/Tk interface ... done
strapply("test", as.numeric)
*** caught bus error ***
address 0x13c, cause 'non-existent physical address'
Traceba
A minor variant might be the following:
library(gsubfn)
strapply(input, "\\d+\\.\\d+E[-+]?\\d+", as.numeric, simplify = rbind)
where:
- as.numeric is used in place of c in which case we do not need combine
- \\d+ matches one or more digits
- \\. matches a decimal point
- [-+]? matches -, +
Try this:
strapply(input, "([0-9]+\\.[0-9]+E-[0-9]+)", c, simplify = rbind,
combine = as.numeric)
On Wed, Nov 18, 2009 at 9:57 AM, baptiste auguie
wrote:
> Dear list,
>
> I'm seeking advice to extract some numeric values from a log file
> created by an external program. Consider the following ex
Dear list,
I'm seeking advice to extract some numeric values from a log file
created by an external program. Consider the following example,
input <-
readLines(textConnection(
"some text
=1.3770E-03 =3.4644E-07
=1.9412E-04 =4.8840E-08
other text
=1.3770E-0
10 matches
Mail list logo