To do this, you can use .First()and .Last()in .Rprofile.
This is a typical R file that was launched at startup and is primarily used to export some default files.
An example .Rprofile:
.First <- function() {
library(ggplot2)
cat("\nSuccessfully loaded .Rprofile at", date(), "\n")
}
.Last <- function() {
cat("\nGoodbye at ", date(), "\n")
}
Related: Expert R users, what's in your .Rprofile?
source
share