Skip to content

Numeric Characters in String

2 messages · Karl Weinmayer, Eik Vettorazzi

#
Hi Karl,
both strategies are possible using gsub:
gsub("([0-9]*).*","\\1",str) #extract numbers
gsub("[^0-9]","",str)  #remove all non-numeric characters

wrap it nicely in an "as.numeric" call to get numeric values.

cheers.

Am 16.09.2011 11:13, schrieb Karl Weinmayer: