[R] remove numbers from string of characters

(Ted Harding) ted.harding at wlandres.net
Mon Oct 18 17:19:11 CEST 2010


On 18-Oct-10 14:58:05, Kurt_Helf at nps.gov wrote:
> Greetings
> I want to remove numbers from a string of characters that
> identify sites so that I can merge two data frames.
> For example, a site in one frame is called
> "001a Frozen Niagara Entrance" whereas the same site
> in the other data frame is called "Frozen Niagara Entrance".
> It seems to me the easiest thing to do would be to remove
> the numbers from the first data frame so the two will match.
> How do I go about removing those numbers?
> Thanks in advance.
> Cheers
> Kurt

Try something based on:

  X <- "001a Frozen Niagara Entrance"
  sub("[[:alnum:]]* ","",X)
  # [1] "Frozen Niagara Entrance"

Hoping this helps!
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 18-Oct-10                                       Time: 16:19:08
------------------------------ XFMail ------------------------------



More information about the R-help mailing list