Re: [R] Number of words in a string

2008-04-10 Thread Hans-Joerg Bibiko
On 10 Apr 2008, at 07:43, Shubha Vishwanath Karanth wrote: So powerful, the gsub... But I really don’t understand the how the regular expressions like *\\S+$, need to be used and how to make best use of it... Any article/material/links that I can go through? A good starting point is:

[R] Number of words in a string

2008-04-09 Thread Shubha Vishwanath Karanth
Hi R, A quick question: How do we find the number of words in a string? Example: C=Have a nice day And the number of words should be 4. any built in function or?... Thanks, Shubha Shubha Karanth | Amba Research Ph +91 80 3980 8031 | Mob +91 94 4886 4510 Bangalore * Colombo *

Re: [R] Number of words in a string

2008-04-09 Thread Markus Gesmann
BY THE FINANCIAL SERVICES AUTHORITY -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shubha Vishwanath Karanth Sent: 09 April 2008 16:21 To: [EMAIL PROTECTED] Subject: [R] Number of words in a string Hi R, A quick question: How do we find the number

Re: [R] Number of words in a string

2008-04-09 Thread Shubha Vishwanath Karanth
* www.ambaresearch.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shubha Vishwanath Karanth Sent: Wednesday, April 09, 2008 8:51 PM To: [EMAIL PROTECTED] Subject: [R] Number of words in a string Hi R, A quick question: How do we find the number

Re: [R] Number of words in a string

2008-04-09 Thread Hans-Joerg Bibiko
On 9 Apr 2008, at 17:29, Markus Gesmann wrote: Would this: sapply(strsplit(C, ), length) work for? or length(unlist(strsplit(C, ))) --Hans __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

Re: [R] Number of words in a string

2008-04-09 Thread Shubha Vishwanath Karanth
York * San José * Singapore * www.ambaresearch.com -Original Message- From: Markus Gesmann [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 09, 2008 9:00 PM To: Shubha Vishwanath Karanth; [EMAIL PROTECTED] Subject: RE: [R] Number of words in a string Would this: sapply(strsplit(C

Re: [R] Number of words in a string

2008-04-09 Thread Christos Hatzis
length(unlist(strsplit(C, ' '))) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shubha Vishwanath Karanth Sent: Wednesday, April 09, 2008 11:21 AM To: [EMAIL PROTECTED] Subject: [R] Number of words in a string Hi R, A quick question

Re: [R] Number of words in a string

2008-04-09 Thread Hans-Joerg Bibiko
Something like that? gsub( {1,}\w+$, , C) __ R-help@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,

Re: [R] Number of words in a string

2008-04-09 Thread Shubha Vishwanath Karanth
* New York * San José * Singapore * www.ambaresearch.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hans-Joerg Bibiko Sent: Wednesday, April 09, 2008 9:10 PM To: [EMAIL PROTECTED] Subject: Re: [R] Number of words in a string On 9 Apr 2008, at 17:29

Re: [R] Number of words in a string

2008-04-09 Thread Shubha Vishwanath Karanth
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shubha Vishwanath Karanth Sent: Wednesday, April 09, 2008 9:01 PM To: Markus Gesmann; [EMAIL PROTECTED] Subject: Re: [R] Number of words in a string Exactly...this is what I wanted... Can we also extract/remove the last

Re: [R] Number of words in a string

2008-04-09 Thread Hans-Joerg Bibiko
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

Re: [R] Number of words in a string

2008-04-09 Thread Gabor Grothendieck
- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hans-Joerg Bibiko Sent: Wednesday, April 09, 2008 9:10 PM To: [EMAIL PROTECTED] Subject: Re: [R] Number of words in a string On 9 Apr 2008, at 17:29, Markus Gesmann wrote: Would this: sapply(strsplit(C, ), length

Re: [R] Number of words in a string

2008-04-09 Thread Gabor Grothendieck
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hans-Joerg Bibiko Sent: Wednesday, April 09, 2008 9:10 PM To: [EMAIL PROTECTED] Subject: Re: [R] Number of words in a string On 9 Apr 2008, at 17:29, Markus Gesmann wrote: Would this: sapply

Re: [R] Number of words in a string

2008-04-09 Thread Hans-Jörg Bibiko
On 09.04.2008, at 17:46, Shubha Vishwanath Karanth wrote: To put it simple, C=c(My Dog, Its really good, Beautiful) Now, SOMEFUNCTION(C) should give: c(My, Its really, ) SOMEFUNCTION - function(x) gsub( *\\w+$, , x) But be aware that this won't work for instance for combining diacritics.

Re: [R] Number of words in a string

2008-04-09 Thread Charilaos Skiadas
On Apr 9, 2008, at 1:27 PM, Hans-Jörg Bibiko wrote: On 09.04.2008, at 17:46, Shubha Vishwanath Karanth wrote: To put it simple, C=c(My Dog, Its really good, Beautiful) Now, SOMEFUNCTION(C) should give: c(My, Its really, ) SOMEFUNCTION - function(x) gsub( *\\w+$, , x) But be aware

Re: [R] Number of words in a string

2008-04-09 Thread Shubha Vishwanath Karanth
Bangalore • Colombo • London • New York • San José • Singapore • www.ambaresearch.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Charilaos Skiadas Sent: Thursday, April 10, 2008 3:10 AM To: Hans-Jörg Bibiko Cc: [EMAIL PROTECTED] Subject: Re: [R] Number