[R] Problem with data.frames
    Peter Dalgaard BSA 
    p.dalgaard at biostat.ku.dk
       
    Mon Aug  4 17:41:19 CEST 2003
    
    
  
"Simon Fear" <Simon.Fear at synequanon.com> writes:
> It's one of the many situations in which I would very much like to
> get a warning or error message, pointing out to me that I had
> absolutely no idea what I was doing.
> 
> Surely that's what warnings are for? For those of us who wonder why
> our code doesn't do what we think it should, until a long time after
> the deadline?
It's rarely advisable to nanny users too much though (as someone said:
protecting users from doing dumb things may also prevent them from
doing smart things). In the case of warnings, it is not a good thing
if they can trigger due to circumstances beyond the user's control.
Consider the following:
f <- function(mydata,...){
  attach(mydata)
  ...do something...
  detach(mydata)
}
mydata <- whatever...
attach(mydata)
f(mydata[1:100,])
What should happen? A warning that "mydata already exists on the
search path" or so, perhaps?
OK, so we just don't do that then. But suppose that f is sitting in a
package and the user has no knowledge of its internals. You have then
the side effect of the package that it implicitly forbids the user to
attach a dataframe called "mydata", even if everything functions
perfectly normally when one is present. Imagine having to explain
that in the package documentation!
-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
    
    
More information about the R-help
mailing list