[R-sig-teaching] pros/cons of teaching attach()

Tyler Smith tyler.smith at EKU.EDU
Thu Sep 23 22:48:45 CEST 2010


  On 09/22/2010 04:36 AM, Gavin Simpson wrote:
>
> I don't use attach() at all; too easy to make mistakes that are
> difficult to track down. I tend not to use $ either as that encourages
> people to use it to go fiddling in the bowels of other lists (objects);
> model$residuals might be OK for lm() models (though not if you've used
> na.exclude for example) but students might be surprised with what they
> get with more complex modelling functions with different residuals.
>
This is going to be a dumb question, but what do you use instead of $ 
for accessing variables in a list? [[]] allows for the same fiddling.

Thanks,

Tyler




More information about the R-sig-teaching mailing list