For my personal programming, I find using with( ) is safer then attach( )
and quicker then $.
For my teaching, I usually try my students to be capable of doing things
"the hard way" so they understand what's under the hood, and only then
introduce then to the shortcuts. Thus, I recommend introducing with( ) after
they are familiar with $ or [[ ]], but avoid attach( ).

Jonathan


-- 
Jonathan Rosenblatt
www.john-ros.com

On Wed, Sep 22, 2010 at 10:36 AM, Gavin Simpson <[email protected]>wrote:

> On Tue, 2010-09-21 at 21:34 -0700, Joshua Wiley wrote:
> > Hi all,
> >
> > I am wondering if anyone teaches the attach function to new students
> > and if so, why?
>
> 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.
>
> If I was really teaching R, I would mention attach() and then show why
> it is bad so I've dealt with the issue on my terms.
>
> G
>
> > I have never taught a class using R, but in small tutorials and
> > providing direct help, I have run across this issue several times.  I
> > have always avoided it, but a couple of times, students had learned to
> > use it in a class (though without much detail) and were rather grumpy
> > with me for using full variable names or with().  New converts,
> > particularly from GUIs like SPSS, already tend to be leery of R, and I
> > hate to make working at the command line more onerous since any typing
> > is more than they are used to, but at the same time a discussion of
> > environments, which I think is necessary to avoid trouble with attach,
> > does not seem like beginner material either.
> >
> > I have wondered about this many times, but was just reminded again by
> > an R-help post.
> >
> > Thanks,
> >
> > Josh
> >
>
> --
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
>  ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
>  Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
>  Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
>  UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>
> _______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
>

        [[alternative HTML version deleted]]

_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-teaching

Reply via email to