On 18-Oct-10 15:03:22, Henrique Dallazuanna wrote:
> See agrep function:
>
> agrep("Frozen Niagara Entrance", "001a Frozen Niagara Entrance") > 0
>
> To remove the numbers:
>
> gsub("\\d", "", "001a Frozen Niagara Entrance")
That results in "a Frozen Niagara Entrance", which is not
what he said he wants (his "numbers" are not purely digital)!
You need sub() and "[:[alnum:]]* " as I suggested previously.
Also "\\w* " would work, since this "\\w" is equivalent to
"[[:alnum:]]":
sub("[[:alnum:]]* ", "", "001a Frozen Niagara Entrance")
# [1] "Frozen Niagara Entrance"
sub("\\w* ", "", "001a Frozen Niagara Entrance")
# [1] "Frozen Niagara Entrance"
> On Mon, Oct 18, 2010 at 12:58 PM, <[email protected]> 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
--------------------------------------------------------------------
E-Mail: (Ted Harding) <[email protected]>
Fax-to-email: +44 (0)870 094 0861
Date: 18-Oct-10 Time: 16:31:20
------------------------------ XFMail ------------------------------
______________________________________________
[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.