hadley / strict

Make R a little bit stricter
235 stars 10 forks source link

Don't allow using attach() on a data frame #33

Open JoFAM opened 6 years ago

JoFAM commented 6 years ago

Quite a few people still learn to attach(df) for working with data. This is a dangerous approach, as you get confusion about where results of a transformation are stored:

attach(iris)
Sepal.Length <- round(Sepal.Length, 0)

Now Sepal.Length and iris$Sepal.Length are two different things.

Personally I would even throw an error from the moment attach() is used. See also the session Good Practice in ?attach.