Re: [R] an operator for "contains"

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Sat 18 Jun 2005 - 06:47:55 EST

On Fri, 17 Jun 2005, Mike R 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?

  value %in% vector

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

No. You can find binary operators fairly effectively by looking at the html help, because they have to have non-alphabetic names (either single characters or beginning and ending with %).

However, there are functions such as setdiff() that you might think of as binary operators that you wouldn't find this way.

         -thomas



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jun 18 07:54:55 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:50 EST