Seeing Global Workspace and dealing with attach and detach
Jeff Newmiller <jdnewmil <at> dcn.davis.ca.us> writes:
In general, creating variables while attached leads to problems such as you describe. Normally the recommendation is to avoid the use of attach and detach entirely in favor of explicit reference to the data frame using [[]], [,], $, and the data= argument supported by many functions.
And with() and within() [as well as transform(), mutate(), subset(), etc.: see http://r4stats.com/2013/01/22/comparing-tranformation-styles/ [sic "tranformation"]