[R] Referring to an object by a variable containing its name: 6 failures

andrewH ahoerner at rprogress.org
Sun Sep 18 21:21:50 CEST 2011

Thanks Josh & Duncan!  That was very clear and helpful. After going back and
reviewing documentation for "{" and "$" I am realizing that R the pattern in
R documentation is simply to tell you the truth, and not to give much effort
to distinguishing confusable choices. Once again, things that seemed crazy
to me become perfectly sensible once understood. I think I need to read
function documentation more the way one reads concept definitions in a math

Josh, one question: Your reasons to avoid attach() seem cogent. However,
Venables, Smith et al. say in “An Introduction to R” 
"A useful convention that allows you to work with many different problems
comfortably together
in the same working directory is
 gather together all variables for any well defined and separate problem in
a data frame
under a suitably informative name;
 when working with a problem attach the appropriate data frame at position
2, and use the
working directory at level 1 for operational quantities and temporary
 before leaving a problem, add any variables you wish to keep for future
reference to the
data frame using the $ form of assignment, and then detach();
 finally remove all unwanted variables from the working directory"

I'm still at the point that I am doing things just because Authority says
so, but unfortunately, everyone is Authority, relative to me. Still, I
wonder if you have any thoughts about why such a venerable authority as
Venables et al. would recomend a programming practice if that practice
should always be avoided. For cognative dissonance form authority conflicts,
that's up there with the Google R stylesheet saying to avoid using S4

Again, my thanks.

View this message in context: http://r.789695.n4.nabble.com/Referring-to-an-object-by-a-variable-containing-its-name-6-failures-tp3817129p3822436.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list