Skip to content
Prev 50893 / 63421 Next

match()/%in% with language objects?

match(x,table) and x%in%table work when x and table are lists of language
objects or expressions.  E.g.,

  expression(quote(1+2), quote(log2(16))) %in% expression(3, quote(1+2),
c(4L,5L,6L,7L))
  #[1]  TRUE FALSE
  list(quote(1+2), quote(log2(16))) %in% list(3, quote(1+2), c(4L,5L,6L,7L))
  #[1]  TRUE FALSE
  match(list(quote(1+2), quote(log2(16))),  list(3, quote(1+2),
c(4L,5L,6L,7L)))
  #[1]  2 NA

With your example data:
  spList[1] %in% spList
  #[1] TRUE
  list(quote(foo)) %in% spList
  #[1] TRUE
  list(quote(nosuchsymbol)) %in% spList
  #[1] FALSE





Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Aug 25, 2015 at 9:12 AM, Ben Bolker <bbolker at gmail.com> wrote: