[R] A %nin% operator?

Ken Williams ken.williams at thomsonreuters.com
Thu Aug 5 18:04:07 CEST 2010


Yeah, and %w/o% seems to have reinvented setdiff(). =)

 -Ken


On 8/5/10 10:53 AM, "David Winsemius" <dwinsemius at comcast.net> wrote:

> The examples in the help page for "%in%" (shared by "match") has the
> definition of a "%w/o%" binary operator.
> 
> "%w/o%" <- function(x,y) x[!x %in% y] #-- x without y
> since:
>   "%in%" <- function(x, table) match(x, table, nomatch = 0) > 0
> It appears that you have just re-invented the without-wheel.


-- 
Ken Williams
Sr. Research Scientist
Thomson Reuters
Phone: 651-848-7712
ken.williams at thomsonreuters.com



More information about the R-help mailing list