[R] Numbers in a string

Petr Savicky savicky at cs.cas.cz
Wed Dec 15 14:21:37 CET 2010


On Wed, Dec 15, 2010 at 11:08:06AM -0200, Henrique Dallazuanna wrote:
> Try this:
> 
>  gsub("[^0-9]", "", "AB15E9SDF654VKBN?dvb.65")

Consider also

  strsplit("AB15E9SDF654VKBN?dvb.65", "[^.0-9][^.0-9]*")
  [[1]]
  [1] ""    "15"  "9"   "654" ".65"

PS.

> On Wed, Dec 15, 2010 at 6:55 AM, Luis Felipe Parra <
> felipe.parra at quantil.com.co> wrote:
> 
> > Hello, I have stings which have all sort of characters (numbers, letters,
> > punctuation marks, etc) I would like to stay only with the numbers in them,
> > does somebody know how to do this?
> >
> > Thank you
> >
> > Felipe Parra



More information about the R-help mailing list