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

Graham Smith myotisone at gmail.com
Wed Sep 22 08:17:39 CEST 2010


Josh

> I am wondering if anyone teaches the attach function to new students
> and if so, why?

I'm not sure whether my approach is the best or worst of both worlds.

I use attach() at the beginning with warnings of it being bad practice
and explain why. But also explain why on occasions, it can make life
easier. Such as your first few lessons in R.

Later we subset the data and then use the data$variable approach and I
remind them of my earlier explanation of attach() and why we are now
using a different approach.

Graham




More information about the R-sig-teaching mailing list