[R] Playing with formulae

Ross Boylan ross at biostat.ucsf.edu
Sat Sep 13 02:22:18 CEST 2003


Thanks.  Not what I was hoping to hear, but it's good to know.  Back to
the drawing board(:  Perhaps since I really don't want to allow
interactions and other exotica, I should just have the names of the
covariates passed in, and then construct the formula from that (with
paste and as.formula?).

A couple of follow up questions.
On Fri, 2003-09-12 at 16:12, Thomas Lumley wrote:
> On Fri, 12 Sep 2003, Ross Boylan wrote:
.....
> 
> >   b) How can I get the response variable out of the "variables"
> >      attribute?  In my example,
> >      response is 1, but attr(t, "variables")[1] is list().
> >      Possible answer: attr(t, "variables")[[response+1]] looks right,
> >      and is of class name.  Hence the interest in question 2.
> 

Is attr(t, "variables")[[response+1]] always the right term, though it
may not be of class name if the response is an expression?

> The "factors" attribute has row names corresponding to variables and
> column names corresponding to terms.
> 
Is the first row name always the response (though it may not be a simple
variable name)?

....
> 
> An example of the sort of thing you're trying to do is in
> untangle.specials() in the survival package, which is used to locate terms
> and variables for strata() and cluster() in coxph().  It uses the dimnames
> of the "factors" attribute as keys.
> 

I'm working on a modified version of those routines, so I'll have
another look.  The strata term was one of the reasons I was mucking
around.

By the way, do you or anyone know what's special about specials?  The
only thing the documentation mentioned (that I saw) was that terms that
were special were flagged as such.


> 	-thomas
> 
> Thomas Lumley			Assoc. Professor, Biostatistics
> tlumley at u.washington.edu	University of Washington, Seattle




More information about the R-help mailing list