On 6/17/05, Mike R <[EMAIL PROTECTED]> wrote:
> k = c(1:9)
> if( length( which(k==3) ) ){ print("contained") }else{ print("not contained") 
> }
> 
> is therre a simple way to test if a vector/list contains a particular value?

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.

> more generally, is the a documentaion page that lists/describes all
> such operators?

help("==") would get you the help page for the actual binary
operators. Since any() isn't an operator, that won't help.

> lastly, if you didn't know the answer to my question, how would you have
> gone about searching for an answer? 

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

-- 
Sarah Goslee
http://www.stringpage.com

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to