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:
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 *
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
*
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
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
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
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
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,
* 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
-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
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
-
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
-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
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.
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
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
16 matches
Mail list logo