[R] test if text is part of vector

Johannes Radinger JRadinger at gmx.at
Fri Jan 20 12:50:01 CET 2012


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.

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 ...



More information about the R-help mailing list