[R] test if text is part of vector
Petr PIKAL
petr.pikal at precheza.cz
Fri Jan 20 12:55:55 CET 2012
Hi
> Hello,
>
> this is a very simple question:
> How can I find out if a word is part of a list of words
>
> like:
> a <- "word1"
> b <- "word4"
>
> vector <- c("word1","word2","word3")
>
> I tried it with match(a,vector)
> but this gives the position of the word.
>
Perhaps
a %in% vector
Regards
Petr
> I am not sure if and how that can be
> done with a logical operator like if:
> IF text is part of vector THEN print "is part"
>
> Probably a very easy thing to do, but I am missing
> the logical operator... and help(if) is not working
>
> best regards,
> johannes
> --
> "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list