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:
Number of words in a string
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
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(" *\
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
3980 8031 | Mob +91 94 4886 4510
> > Bangalore * Colombo * London * New York * San José * Singapore *
> > www.ambaresearch.com
> >
> > -Original Message-
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROT
trings without using ?strsplit ?
>
> Shubha Karanth | Amba Research
> Ph +91 80 3980 8031 | Mob +91 94 4886 4510
> Bangalore * Colombo * London * New York * San José * Singapore *
> www.ambaresearch.com
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROT
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)
sh
on * New York * San José * Singapore *
www.ambaresearch.com
-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 st
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
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
31 | Mob +91 94 4886 4510
Bangalore * Colombo * London * New 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] Nu
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 rea
ew York * San José * Singapore *
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 quest
REGULATED 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
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 *
16 matches
Mail list logo