[R] Number of words in a string

Shubha Vishwanath Karanth shubhak at ambaresearch.com
Wed Apr 9 17:27:04 CEST 2008


To put in more general,

C=c("My Dog", "Its really good", "Beautiful")

And the resultant output should be
[1] 2 3 1

...the number of words....

Thank you...
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: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Shubha Vishwanath Karanth
Sent: Wednesday, April 09, 2008 8:51 PM
To: r-help at stat.math.ethz.ch
Subject: [R] Number of words in a string

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 * London * New York * San José * Singapore * www.ambaresearch.com

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

This e-mail may contain confidential and/or privileged i...{{dropped:10}}



More information about the R-help mailing list