[R] attributes of a data.frame

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Nov 23 18:17:12 CET 2005


Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:

> Why do you have names like 'pctx723' in the first place?
> 
> I have never had a difficulty with using informative column names whereas 
> you seem to require the extra complication of `variable labels'.
> Now we have `` and allow _ in syntactic names it is even easier than it 
> was.

But do we want to have `Maternal height (inches)` as a variable name?
Imagine a multiple regression with a few dozen such terms as
predictors.  

We do have the comment attribute (as in help(comment)), but we're not
using it much. There could be some reason in using a such a comment,
if present, and possibly optionally, to name dimnames in tables and
for x/y labels in plots. I'm not sure it is easy to do without
disrupting existing code, though. I notice in particular that the
comment attribute is retained according to rules that might not be
what users expect.

 
> On Tue, 22 Nov 2005, Michael Friendly wrote:
> 
> > It's hard for me to resist dipping my oar into this...
> >
> > Variable labels are so generally useful, both in documenting a
> > dataset (what was 'pctx723' again?) and in producing readable
> > output and graphs that it is a shame they are not provided in
> > base R.  If they were (and were used in print and plot methods,
> > when available) it would avoid a lot of the necessity to specify
> > xlab= and ylab= in graphs, or, perhaps worse, ending up with
> > pctx723 as the label in your presentation.
> >
> > -Michael
> >
> >> On 11/21/2005 2:51 PM, Adrian DUSA wrote:
> >>
> >>>> On Monday 21 November 2005 22:41, Duncan Murdoch wrote:
> >>>
> >>>>>> [...snip...]
> >>>>>> Not all dataframes have the variable.labels attribute.  I'm guessing
> >>>>>> you've installed some contributed package to add them, or are importing
> >>>>>> an SPSS datafile using read.spss.  So don't expect varlab() or
> >>>>>> variable.labels() function to be a standard R function.
> >>>
> >>>>
> >>>> Aa-haa... of course you are right: I read them via read.spss. I understand.
> >>>> Now, just to the sake of it, would it be wrong to make it standard?
> >>>> Is there a special reason not to?
> >>
> >>
> >> I think it's just that the R core developers don't see the need for
> >> them.  If something is worth documenting, then you should write an .Rd
> >> file or a vignette about it, and that gives you more flexibility than a
> >> one line label.
> >>
> >> I think there are definitely developers out there who disagree with this
> >> point of view, and I'm pretty sure I've seen a contributed package that
> >> offered support for this, but I can't remember which one right now.  So
> >> that's another reason why it's not in the base:  it doesn't need to be,
> >> you can just go find and install that contributed package!
> 
> 
> -- 
> 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
> 
> ______________________________________________
> R-help at 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
> 

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907




More information about the R-help mailing list