From wdunlap at tibco.com  Mon Dec  6 19:03:27 2010
From: wdunlap at tibco.com (William Dunlap)
Date: Mon, 6 Dec 2010 10:03:27 -0800
Subject: [Rd] when to use pairlist instead list
Message-ID: <77EB52C6DD32BA4D87471DCD70C8D70003B1DD94@NA-PA-VBE03.na.tibco.com>

I was writing some assertion tests for modelling-related
code I had written and was surprised to see one test
fail because the "specials" attribute of the output of
terms() is a "pairlist" instead of a "list".  In 2.12.0
I get:

  > dput(attr(terms(y~Spec(x1)+x2, specials=c("Spec")), "specials"))
  list(Spec = 2L)
  >  all.equal(attr(terms(y~Spec(x1)+x2, specials=c("Spec")),
"specials"), list(Spec=2L))
  [1] "Modes: pairlist, list"
  >  all.equal(attr(terms(y~Spec(x1)+x2, specials=c("Spec")),
"specials"), pairlist(Spec=2L))
  [1] TRUE
  >  identical(attr(terms(y~Spec(x1)+x2, specials=c("Spec")),
"specials"), pairlist(Spec=2L))
  [1] TRUE

I was wondering if there was a reason for using pairlist
instead of list here or it it was just an historical
artifact.  In general, when should one use pairlists?

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 



[Rd] when to use pairlist instead list
William Dunlap