[R] attr function

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Wed Feb 5 14:46:03 CET 2003


attr(attr(b, "terms"), "term.labels")

works, as I would have expected.  This is part of the "terms" attribute, 
not of the model frame per se.

On Wed, 5 Feb 2003, Shawn Way wrote:

> 
> I've been trying unsuccessfully to extract the term labels from a model
> frame using the attr function.
> 
> The code is as follows
> 
> a <- data.frame(col1=c(1,2,3,2,1,3),col2=c(2,4,7,6,4,3))
> b <- model.frame(col2~col1,data=a)
> 
> Now the term.labels attribute is col1, but how do I get this from the b data
> frame attributes?

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list