s-news
[Top] [All Lists]

Re: pattern

To: Pravin Jadhav <pravinj@gmail.com>
Subject: Re: pattern
From: Dimitrios Rizopoulos <Dimitris.Rizopoulos@med.kuleuven.be>
Date: Tue, 16 May 2006 18:16:30 +0200
Cc: s-news <s-news@lists.biostat.wustl.edu>
In-reply-to: <679f8b3f0605160847k4dee660bxf8a2a37fbf026ad3@mail.gmail.com>
References: <679f8b3f0605160847k4dee660bxf8a2a37fbf026ad3@mail.gmail.com>
User-agent: Internet Messaging Program (IMP) 3.2-cvs
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


<Prev in Thread] Current Thread [Next in Thread>
  • pattern, Pravin Jadhav
    • Re: pattern, Dimitrios Rizopoulos <=