Re: [R] Number of words in a string

From: Hans-Joerg Bibiko <bibiko_at_eva.mpg.de>
Date: Wed, 09 Apr 2008 17:53:56 +0200

On 9 Apr 2008, at 17:44, Shubha Vishwanath Karanth wrote:
> Got all the answers using ?strsplit... Is there any way without
> using string split?... More specifically... How can I just extract
> the last word in all the strings without using ?strsplit ?

Oops, sorry.

gsub(" *\w+$", "", C)

should work.

--Hans



R-help_at_r-project.org 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. Received on Wed 09 Apr 2008 - 16:04:42 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 Wed 09 Apr 2008 - 16:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive