[R] test if text is part of vector

2012-01-20 Thread Johannes Radinger
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

Re: [R] test if text is part of vector

2012-01-20 Thread Petr PIKAL
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

Re: [R] test if text is part of vector

2012-01-20 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 20/01/12 12:50, Johannes Radinger wrote: 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

Re: [R] test if text is part of vector

2012-01-20 Thread Johannes Radinger
Hi, thank you very much... %in% is the operator I was looking for. cheers, johannes Original-Nachricht Datum: Fri, 20 Jan 2012 13:01:54 +0100 Von: Rainer M Krug r.m.k...@gmail.com An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] test if

Re: [R] test if text is part of vector

2012-01-20 Thread R. Michael Weylandt michael.weyla...@gmail.com
You also might look at grepl() if you have time: it allows regular expressions and will be a little (a lot?) more flexible in how you define a match if you want to ignore things like capitalization. (mnemonic: the L in grepl indicates its like grep but returns logicals instead of positions)