[R] Bug in "transform"?
    Prof Brian Ripley 
    ripley at stats.ox.ac.uk
       
    Wed Dec  3 09:06:45 CET 2008
    
    
  
On Tue, 2 Dec 2008, hadley wickham wrote:
>> The underlying issue is actually not in transform() but in data.frame():
>>
>>> aq <- airquality[sample(1:153,6),]
>>> data.frame(aq, list(a=1,b=2))
>> Error in data.frame(aq, list(a = 1, b = 2)) :
>>  arguments imply differing number of rows: 6, 1
>>> data.frame(aq, list(a=1))
>>    Ozone Solar.R Wind Temp Month Day a
>> 3      12     149 12.6   74     5   3 1
>> 31     37     279  7.4   76     5  31 1
>> 34     NA     242 16.1   67     6   3 1
>> 65     NA     101 10.9   84     7   4 1
>> 59     NA      98 11.5   80     6  28 1
>> 133    24     259  9.7   73     9  10 1
>>
>
> Is this a bug or a "feature"?
As documented:
   Objects passed to data.frame should have the same number of rows, but
   atomic vectors, factors and character vectors protected by I will be
   recycled a whole number of times if necessary.
How did you manage to miss that in the help page?
>
> Hadley
>
> -- 
> http://had.co.nz/
>
-- 
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