[R] Number of words in a string

Markus Gesmann Markus.Gesmann at libero.uk.com
Wed Apr 9 17:29:55 CEST 2008


Would this:

sapply(strsplit(C, " "), length)

work for?



Markus Gesmann │Associate Director│Libero Ventures Ltd, One Broadgate, London EC2M 2QS
tel: +44 (0)207 826 9080│ dir: +44 (0)207 826 9085│fax: +44 (0)207 826 9090 │www.libero.uk.com

A Lehman Brothers Company

AUTHORISED AND REGULATED BY THE FINANCIAL SERVICES AUTHORITY

-----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: 09 April 2008 16:21
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 message is intended for the personal and confidential use for the designated recipient(s) named above.  If you are not the intended recipient of this message you are hereby notified that any review, dissemination,  distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction or as an official statement of Libero Ventures Ltd.  Email transmissions cannot be guaranteed to be secure or error-free. Therefore we do not represent that this information is complete or accurate and it should not be relied upon as such.  All information is subject to change without notice.


More information about the R-help mailing list