And to expand a bit: only the site file tries to put objects into the
base package. The local .Rprofile file would put them into the global
environment. So there's still support for .First and .Last, but it has
changed.
This abuses things a bit, but appears to work in an Rprofile.site file:
assign(".Last", function() if (interactive()) message("Goodbye!"),
.AutoloadEnv)
The .AutoloadEnv environment is the place that autoload() writes in the
base package, and it's generally on the search path, so the .Last
function will be found. I haven't checked whether it will be run if
there's also a .Last defined in the global environment.
Duncan Murdoch
On 07/06/2021 10:24 a.m., Bert Gunter wrote:
According to the News file for 4.1.0 -- you should always check there first
for such things --
"The base environment and its namespace are now locked (so one can no
longer add bindings to these or remove from these)."
So the docs do seem to need updating.
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Mon, Jun 7, 2021 at 12:15 AM Paul Louisell <plout...@gmail.com> wrote:
Here's my relevant OS / version info for background:
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Here's the problem: I've inserted the following lines *only *into my
Rprofile.site file in the etc folder:
if(interactive()){
.Last=function(){
timestamp(stamp=date(), prefix = "##------ ", suffix = " ------##")
savehistory()
}
}
This is a basic .Last function to automatically insert a timestamp into the
history and save it at the end of an interactive R session. Prior to R
4.1.0, I'd never received an error from these lines. But in version 4.1.0
on startup, I get this error:
Error: cannot add binding of '.Last' to the base environment
And (as expected given the error) the .Last function is not in the
workspace:
.Last
Error: object '.Last' not found
The same thing happens when I start up the 32-bit version. Section 10.8
(pg. 54) of *R-intro.pdf *still has the documentation for .First and .Last,
and shows examples where you place the function definitions in the
Rprofile.site file, as well as other locations. *fullrefman.pdf *also has
documentation for these functions. So my question:
- Is this a bug? Or does R not support .First / .Last anymore, and the
documents just need updating?
Thanks for your help with this,
Paul Louisell
[[alternative HTML version deleted]]
______________________________________________
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.
[[alternative HTML version deleted]]
______________________________________________
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.