[R] Simple loop
    peter dalgaard 
    pdalgd at gmail.com
       
    Sat May  7 18:46:48 CEST 2011
    
    
  
On May 7, 2011, at 17:21 , Hadley Wickham wrote:
>> 
>> Well, ave() uses interaction(...) and interaction() has a "drop" argument, so
>> 
>>> with(x, ave(H, Site, Prof, drop=TRUE, FUN=function(y)y-min(y)))
>> [1]  8  0 51  0 33 22 21  0
> 
> I don't understand why this isn't the default.
> 
> Hadley
Defensive programming, maybe? It's not the default for interaction(), which makes sense, and if you pass a non-default option, you cannot revert it. Not that I can think up a case where you'd actually want to process the empty levels either.
-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com
    
    
More information about the R-help
mailing list