you can try something like:
sapply(sapply(test1, unpaste, sep = "+"), length)
I hope it helps.
Best,
Dimitris
--
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
Quoting Pravin Jadhav <pravinj@gmail.com>:
> Hello,
>
> I have the following vector
> > test1<-c("A+B", "A+C+D", "A+G+B")
> I am interested in knowing the number of letters in each character
> string.
> The output should be (2, 3, 3).
>
> I can do this when there is no "+" sign in between
> >test2<-c("AB","ACD","AGB")
> >attr(regexpr("[A-Z]+",test2), "match.length")
> [1] 2 3 3
>
> I am wondering how to obtain similar output for "test1". Any pointers
> are
> appreciated.
>
> Pravin
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
|