On 21/01/2021 5:20 p.m., J C Nash wrote:
In a separate thread Jeff Newmiller wrote:
rm(list=ls()) is a bad practice... especially when posting examples. It doesn't
clean out everything and it removes objects created by the user.
This query is to ask
1) Why is it bad practice to clear the workspace when presenting an example?
I'm assuming here that people who will try R-help examples will not run them in
the
middle of something else, which I agree would be unfortunates.
I think that's exactly the concern. I doubt it would have happened in
this instance, but in other cases, people might copy and paste a
complete example before reading it. It's safer to say: "Run this code
in a clean workspace:", rather than cleaning it out yourself.
Duncan Murdoch
However, one of the
not very nice aspects of R is that it is VERY easy to have stuff hanging around
(including
overloaded functions and operators) that get you into trouble, and indeed make
it harder
to reproduce those important "minimal reproducible examples". This includes
the .RData
contents. (For information, I can understand the attraction, but I seem to have
been
burned much more often than I've benefited from a pre-warmed oven.)
2) Is there a good command that really does leave a blank workspace? For testing
purposes, it would be useful to have an assured blank canvas.
Yes, start R with
R --vanilla
Duncan Murdoch
This post is definitely not to start an argument, but to try to find ways to
reduce
the possibilities for unanticipated outcomes in examples.
Cheers, JN
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.