Re: [R] Identifying common prefixes from a vector of words, and delete those prefixes

From: <>
Date: Thu, 31 Jul 2008 14:21:55 +0100

> For example, c("", "", "
> animal"). How can I identify the common prefix is ""
> and delete it to give c("dog", "cat", "rat") ?
foo <- c("", "", "") sub("", "", foo)

Being pedantic, "" is a suffix not a prefix since it comes afterwards.


Mathematical Sciences Unit

ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 31 Jul 2008 - 13:30:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 31 Jul 2008 - 14:33:03 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive