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<[email protected]> 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? > > > thanks! > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

