[R] parsing numeric values

2009-11-18 Thread baptiste auguie
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 =

Re: [R] parsing numeric values

2009-11-18 Thread Henrique Dallazuanna
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.

Re: [R] parsing numeric values

2009-11-18 Thread Gabor Grothendieck
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 -, +

Re: [R] parsing numeric values

2009-11-18 Thread baptiste auguie
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'

Re: [R] parsing numeric values

2009-11-18 Thread Gabor Grothendieck
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,

Re: [R] parsing numeric values

2009-11-18 Thread Bert Gunter
: 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

Re: [R] parsing numeric values

2009-11-18 Thread baptiste auguie
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

Re: [R] parsing numeric values

2009-11-18 Thread Gabor Grothendieck
[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

Re: [R] parsing numeric values

2009-11-18 Thread Gabor Grothendieck
[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

Re: [R] parsing numeric values

2009-11-18 Thread baptiste auguie
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