Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] character occurence within a string

Marc Mamin

2005-02-21

Replies:

Hello,

I'm looking for a function that counts the occurences of a given character within a string.

f('|','ab|c|d') => 2


More precisely, I need to complete a vector of strings to ensure that all elements have the same count of a "separator":

 a|b|c
 a
 |a|b|c|d

 =>

 a|b|c||
 a||||
 |a|b|c|d

I guess that scan makes use of an internal function that would do the job...


Thanks,

Marc Mamin

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.