[R] How to strip everything after second whitespace?
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Nov 6 14:06:53 CET 2009
Try this:
library(gsubfn)
strapply(nam, "^\\w+ \\w+", simplify = c)
On Fri, Nov 6, 2009 at 3:11 AM, johannes rara <johannesraja at gmail.com> wrote:
> How to split everything after second whitespace char using regular
> expression? I want to remove A, B, C and D from these names:
>
> nam <- c("Smith John A", "Smith David B C", "Smith Ryan C D")
More information about the R-help
mailing list