Skip to content
Prev 72049 / 398498 Next

an operator for "contains"

On 6/17/05, Mike R <mike.rstat at gmail.com> wrote:
Yes, several. Here's one:
k <- 1:9
if(any(k == 3)) {
cat("is an element\n") } else {
cat("not an element\n") }

I don't recommend that for floating point numbers, though.
help("==") would get you the help page for the actual binary
operators. Since any() isn't an operator, that won't help.
There are a variety of ways to find answers in R, although if you
aren't certain what your keyword should be, it may take a few tries.

help(), help.search(), and apropos() may all be useful.

Sarah