Try this:

!list %in% c("aa", "bb")

On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi <lave...@unipa.it> wrote:

> Hi everybody,
>
> I have the following problem. I have a vector containing character
> elements,
> such as:
>
> list = c("aa","bb","cc","dd","ee")
>
> I want to create an index which identifies the elements that are different
> from, e.g. "aa" and "bb".
>
> When I do the following:
>
> jj = list!="aa" & list!="bb"
>
> > jj
> [1] FALSE FALSE  TRUE  TRUE  TRUE
>
> I do the job. But I wonder whether there is a shorter command to compare
> the
> elements of 'list' directly to both "aa" and "bb", avoiding the repetition
> of '& list!=...' and get a result such as jj
>
> thanks!
>
>
>
>
> --
> Andrea Mario Lavezzi
> currently visiting the University of Oxford, Nuffield College
>
> Dipartimento Studi su Politica, Diritto e Societą
> Piazza Bologni 8
> 90134 Palermo, Italy
> tel. ++39 091 23892208
> fax  ++39 091 6112023
> skype: lavezzimario
> email: lave...@unipa.it
> web: http://www.unipa.it/~lavezzi <http://www.unipa.it/%7Elavezzi>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@r-project.org 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.
>
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to