docker容器启动时自动启动脚本_[R]Rstudio project 启动时自动运行某个函数

69ce6223d839ec3dd1a11302866bbb3c.png

Rstudio project启动时如果在project根目录下有.Rprofile文件,就会执行。因此可以把这个需要运行的函数放到.Rprofile文件中,再把.Rprofile放到project目录下。

一个.Rprofile的例子:

# 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)})
.First <- function(){
#Sys.setenv("R_ZIPCMD" = "d:/Rtools/bin/zip.exe")
options(defaultPackages=c(getOption("defaultPackages"),"tidyverse","cowplot","stringr","rio","strF","pacman"))
cat("014")
#source('R/20180130strF_functions.R')
wens()
}
# 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("014")是清屏作用。

如果不用project也可以设定。

https://zhuanlan.zhihu.com/p/56304655

参考:

Using Projects​support.rstudio.com
e0cbc7391b60adc57023d1967f875f8d.png
Automatically run R code when RStudio project is opened​stackoverflow.com
8872ce68e2bf8d878b80d93a053b65cc.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值