From wdunlap at tibco.com  Fri Sep 14 16:43:15 2012
From: wdunlap at tibco.com (William Dunlap)
Date: Fri, 14 Sep 2012 14:43:15 +0000
Subject: [Rd] as.data.frame.character lacks nm= argument
In-Reply-To: <50533038.9040808@stats.ox.ac.uk>
References: <E66794E69CFDE04D9A70842786030B9331BFED@PA-MBX04.na.tibco.com>
	<CACk-te1N4cN=cNeunL8zSn6SUVRis+rgbb8gvVg7mx61b2wdbQ@mail.gmail.com>
	<50533038.9040808@stats.ox.ac.uk>
Message-ID: <E66794E69CFDE04D9A70842786030B9331C41E@PA-MBX04.na.tibco.com>

Thanks Brian,

I am not sure why the user who ran into this problem was using
   as.data.frame(theColumn, nm=theName)
but it may have been an attempt to make a data.frame with a
variable for a column name, which is a pain when calling data.frame.

It also is faster, but I doubt that was the reason:
  > system.time(for(i in 1:1e4)data.frame(x=log(seq_len(100))))
     user  system elapsed 
     1.06    0.00    1.06 
  > system.time(for(i in 1:1e4)as.data.frame(log(seq_len(100))))
     user  system elapsed 
     0.62    0.00    0.63 
  > system.time(for(i in 1:1e4)as.data.frame(log(seq_len(100)), nm="x"))
     user  system elapsed 
     0.17    0.00    0.17  

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]
> Sent: Friday, September 14, 2012 6:25 AM
> To: Bert Gunter
> Cc: William Dunlap; r-devel at r-project.org
> Subject: Re: [Rd] as.data.frame.character lacks nm= argument
> 
> On 13/09/2012 21:48, Bert Gunter wrote:
> > Bill:
> >
> > as.data.frame.character() has no nm, argument, so providing one causes
> > the error as you can see from the code. Presumably, this is what you
> > meant by bug/inconsistency, right?
> 
> This is using an undocumented argument, 'nm'.  I don't believe anything
> is said about what might happen if you do that except that it will be
> passed to methods -- they are not obliged to accept it.
> 
> If it were intended for this to be a feature, I think the author might
> have chosen a less opaque name than 'nm'.
> 
> Where we go from here is under discussion in R-core.
> 
> >
> > -- Bert
> >
> > On Thu, Sep 13, 2012 at 1:32 PM, William Dunlap <wdunlap at tibco.com> wrote:
> >> Is the following behavior with as.data.frame(nm=...) a bug?  It is an inconsistency:
> >>
> >>> as.data.frame(LETTERS[1:10], nm="FirstTenLetters")
> >> Error in as.data.frame.vector(x, ..., nm = nm) :
> >>    formal argument "nm" matched by multiple actual arguments
> >>
> >> nm= works for integer arguments:
> >>
> >>> as.data.frame(1:10, nm="OneToTen")
> >>     OneToTen
> >> 1         1
> >> 2         2
> >> 3         3
> >> 4         4
> >> 5         5
> >> 6         6
> >> 7         7
> >> 8         8
> >> 9         9
> >> 10       10
> >>
> >> Bill Dunlap
> >> Spotfire, TIBCO Software
> >> wdunlap tibco.com
> >>
> >> ______________________________________________
> >> R-devel at r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> >
> >
> 
> 
> --
> 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



[Rd] as.data.frame.character lacks nm= argument
William Dunlap