Re: [R] find numbers in a line with letters

2009-08-26 Thread Bert Gunter
3.32 10.00 Bert Gunter Genentech Nonclinical Biostatisics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steve Lianoglou Sent: Wednesday, August 26, 2009 3:49 PM To: Martin Batholdy Cc: r-help@r-project.org Subject: Re: [R] find numb

Re: [R] find numbers in a line with letters

2009-08-26 Thread Steve Lianoglou
Hi, On Aug 26, 2009, at 6:38 PM, Martin Batholdy wrote: hi, is there an easy way to extract numbers from a string? for example I have; "this Item costs 3.32 Dollars" is there an easy way to extract the 3.32 as a number? Regular expressions to the rescue? Perhaps you'll need to fine tune i

Re: [R] find numbers in a line with letters

2009-08-26 Thread Gabor Grothendieck
Try this: library(gsubfn) s <- "this item costs 3.32 Dollars" strapply(s, "[0-9][0-9.]*", as.numeric)[[1]] See http://gsubfn.googlecode.com for more info. On Wed, Aug 26, 2009 at 6:38 PM, Martin Batholdy wrote: > hi, > > is there an easy way to extract numbers from a string? > > for example I ha