Re: [R] parsing numeric values

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

Re: [R] parsing numeric values

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

Re: [R] parsing numeric values

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

Re: [R] parsing numeric values

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

Re: [R] parsing numeric values

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

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 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' Traceba

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 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 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

[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 =1.3770E-03 =3.4644E-07 =1.9412E-04 =4.8840E-08 other text =1.3770E-0