Re: [R] terms.inner

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Tue 05 Sep 2006 - 14:31:39 GMT

On Tue, 5 Sep 2006, Terry Therneau wrote:

> Question:
> I am trying to impliment a function in R that we use quite regularly in
> Splus, and it fails due to a lack of the "terms.inner" function in R.
> The substitute is?
>
> Part question and part soapbox:
> Why remove terms.inner from R? It's little used, but rather innocuous.

AFAIK it wasn't removed, it just hasn't ever been implemented. Probably no-one in the early years of R tried to port any code that used it -- there were a number of functions added back then just because the survival package used them, such as subscripting on terms objects.

> Mostly soapbox:
> I figured it was no big deal, as I originally discovered the use of
> terms.inner from reading the plot.gam function. So I'd just see what
> plot.gam does in R.
> > plot.gam
> Error: object "plot.gam" not found
>
> Ok, I know this function has to exist. I even remember that there is some
> sort of multi-colon secret handshake that will convince R to let you look
> at it, although I don't remember the form. This Nixonesque passion with
> hiding things is one of the reasons I still prefer Splus.

Perhaps not the best soapbox example. There are at least two gam implementations, but they are both in add-on packages. Neither of them hides its plot.gam in a namespace, but you do need to install and load the package. You presumably want Trevor Hastie's one, which is in the "gam" package, rather than Simon Woods' one in the "mgcv" package.

BTW, termplot() does many of the same things as Hastie's plot.gam(). It is also not hidden. If I understand correctly what terms.inner does, termplot() uses two functions:

     pf <- envir
     carrier <- function(term) {
         if (length(term) > 1)
             carrier(term[[2]])
         else eval(term, data, enclos = pf)
     }
     carrier.name <- function(term) {
         if (length(term) > 1)
             carrier.name(term[[2]])
         else as.character(term)
     }

to do the job.

         -thomas

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley@u.washington.edu	University of Washington, Seattle

______________________________________________
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 and provide commented, minimal, self-contained, reproducible code. Received on Wed Sep 06 00:35:55 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 07 Sep 2006 - 07:51:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.