[R] Partial comparison in string vector

Moshe Olshansky m_olshansky at yahoo.com
Wed Aug 22 01:57:04 CEST 2007


Use grep("^e",x) if you are looking for the entries
where e is the first character.

--- Vladimir Eremeev <wl2776 at gmail.com> wrote:

> 
> Hi!
> 
> seq(along=x) %in% grep("e",x)
> 
> 
> 
> Steve Powell-4 wrote:
> > 
> > I have a vector of strings
> > x=c("w","ex","ee")
> > And I want to get a logical vector showing the
> positions where my search
> > string "e" matches the elements partially, i.e. is
> at least the left-hand
> > part of the target strings, i.e. I want to get a
> vector FALSE TRUE TRUE.
> > 
> 
> -- 
> View this message in context:
>
http://www.nabble.com/Partial-comparison-in-string-vector-tf4304145.html#a12251593
> Sent from the R help mailing list archive at
> Nabble.com.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>



More information about the R-help mailing list