Is it possible to execute a command automatically upon launch in R? -


i use r gui app (r.app). when open app, loads data (e.g. .rapp.history or .rdata) working directory. however, possible execute commands or functions automatically upon launch?

i want load libraries such ggplot2 or plyr, use on session.

you can edit rprofile.site , add desired commands functions .last , .first respectively.

more info rprofile.site: here

at startup, r source rprofile.site file. .rprofile file source in current working directory. if doesn't find it, 1 in user's home directory. there 2 special functions can place in these files. .first( ) run @ start of r session , .last( ) run @ end of session.

that said, can edit function .first() load desired libraries.

.first <- function() {   library("dplyr")   library("ggplot2") } 

you can edit same file , command, used purpose:

options(defaultpackages=c(getoption("defaultpackages"),    "dplyr","ggplot2")) 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -