Category: Cutomize Startup

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 Rprofile.site. 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 Rprofile.site 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")
  options(help_type="html")

# set a site library
# .Library.site <- 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(){
library(Hmisc)
library(R2HTML)
library(Rcmdr)
setwd("C:/Softwares/RWorkspace")
load(".RData")
cat("\nWelcome at", date(), "\n")
cat("\nYour Current Working Directory is:", getwd(), "\n")
}

.Last <- function(){
save.image()
savehistory(".Rhistory")
cat("\nGoodbye at ", date(), "\n")
}