[R] Re: [S] Labels wrong with lrm

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Jul 28 18:47:40 CEST 2001


On Sat, 28 Jul 2001 fharrell at virginia.edu wrote:

> Dear Jan,
>
> Thank you very much for your excellent description of the
> problem and the self-contained test code.  This is a
> problem that I've been meaning to either document better
> or solve for some time.  The root of the problem is with
> the builtin S-Plus terms.inner function:
>
> > attr(terms.inner(asthma ~ pol(age,kx) + smok),'variables')
> expression(age, kx, smok)
>
> You can see that terms.inner inappropriately includes kx
> as an independent variable as it does not know that
> the first argument to pol is the special variable.
> When a constant replaces kx, all is well.
>
> As I am relying on the C code called by terms.inner to
> do the job, I don't have a ready solution.  I would
> be happy if someone comes up with a solution.  The
> all.vars function in the R language has the same
> limitation:
>
> all.vars(asthma ~ pol(age,kx) + smok)
> [1] "asthma" "age"   "kx"   "smok"

Well,

1) all.vars comes from S, and works the same under R.

2) I don't think it is a limitation.  all.vars is described as

Description:

     Return a character vector containing all the names which occur in
     an expression or call.

and kx is such a name.  Indeed, there is no way to know from just the
formula if it is length n-vector or a scalar.   I don't know what pol()
is, but guess it is from your library, in which case the interpretation
may well depend on where (if anywhere) that library is in the search path.

If you want special-purpose names in formulae (like strata) you need to
extend the formula-handling code.  Neither S4 nor R make that easy.

Brian

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list