Customize Startup

No Comments

There are a lot of ways you can customize the R startup. To begin with I kept it simple as highlighted in blue. The customization can be done via the initialization file called R always sources this file first and is found under the install directory’s \etc folder. I’ve added two functions .First() and .Last(). .First() executes at the start of the R session and .Last() executes at the end of the session. The changes made to the as below.

# Things you might want to change

# options(papersize="a4")
# options(editor="notepad")
# options(pager="internal")

# set the default help type
# options(help_type="text")

# set a site library
# <- file.path(chartr("\\", "/", R.home()), "site-library")

# set a CRAN mirror
# local({r <- getOption("repos")
#       r["CRAN"] <- "http://my.local.cran"
#       options(repos=r)})

# Give a fortune cookie, but only to interactive sessions
# (This would need the fortunes package to be installed.)
#  if (interactive())
#    fortunes::fortune()

.First <- function(){
cat("\nWelcome at", date(), "\n")
cat("\nYour Current Working Directory is:", getwd(), "\n")

.Last <- function(){
cat("\nGoodbye at ", date(), "\n")

Leave a Reply

Your email address will not be published. Required fields are marked *