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
ax =1.3770E-03 bx =3.4644E-07
ay =1.9412E-04 by =4.8840E-08
other text
aax =
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
baptiste.aug...@googlemail.com wrote:
Dear list,
I'm seeking advice to extract some numeric values from a log file
created by an external program.
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 -, +
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'
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,
: Wednesday, November 18, 2009 3:57 AM
To: r-help
Subject: [R] parsing numeric values
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
ax =1.3770E-03 bx
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 numeric values from a log file
created by an external program. Consider the following example,
input -
readLines(textConnection(
some text
ax
[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 numeric values from a log file
created by an external program. Consider the following example
[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 numeric values from a log file
created by an external program. Consider the following
with NA's).
Best,
Bert Gunter
Genentech Nonclinical 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
10 matches
Mail list logo