Customizing Startup

You can customize the R environment through a site initialization file or a directory initialization file. R will always source the file first. On Windows, the file is in the C:\Program Files\R\R-n.n.n\etc directory. You can also place a .Rprofile file in any directory that you are going to run R from or in the user home directory.

At startup, R will source the file. It will then look for a . Rprofile file to source in the current working directory. If it doesn't find it, it will look for one in the user's home directory. There are two special functions you can place in these files. .First( ) will be run at the start of the R session and .Last( ) will be run at the end of the session.

# Sample file

# Things you might want to change
# options(papersize="a4")
# options(editor="notepad")
# options(pager="internal")

# R interactive prompt
# options(prompt="> ")
# options(continue="+ ")

# to prefer Compiled HTML
help options(chmhelp=TRUE)
# to prefer HTML help
# options(htmlhelp=TRUE)

# General options
options(tab.width = 2)
options(width = 130)

.First <- function(){
  cat("\nWelcome at", date(), "\n")

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

Going Further

To explore customizing the RStudio interface, try this RStudio course which is taught by Garrett Grolemund, data scientist for RStudio.