Hello all,

I need to count the number of times certain characters occur in a
string. The only way I have found so far to accomplish this is by using
strsplit i.e.

my.string <- "DDDRRHIH"
my.char   <- "D"
num.char <- -1 + length(unlist(strsplit(my.string,my.char)))

now you probably won't be surprised if I say that this has proven to be
extremely slow (I am not sure exactly why though, is it because strsplit
creates new list for every call?). Is there an alternative way to do
this short of going to compiled code?

many thanks,





-- 
Murad Nayal M.D. Ph.D.
Department of Biochemistry and Molecular Biophysics
College of Physicians and Surgeons of Columbia University
630 West 168th Street. New York, NY 10032
Tel: 212-305-6884       Fax: 212-305-6926

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to