打开 RStudio 项目时自动运行 R 代码

打开 RStudio 项目时自动运行 R 代码

问题描述:

我在另一个问题中编写了一个 R 函数来更新包的版本号.我在 GitHub 和 RStudio 上做了很多工作,如果每次打开某个项目时自动运行这个函数(或者更好的是,做一个 git commit/push,但是我会安全一段时间(而且更精确)我认为这更难做到).但我不知道该怎么做,或者这是否可能.

I wrote an R function that updates the version number of a package in another question. I work a lot with GitHub and RStudio, and it would safe me quite some time (plus be much more precise) if this function was automatically run every time I opened a certain project (or better yet, make a git commit/push, but I assume that is harder to do). But I don't know how to do this or if this is even possible.

我可以在每次启动 R 时使用 .Rprofile 来运行 R 代码,所以我可以在每次启动 R 时更新版本(或者内置它只更新版本(如果日期不是今天或某事)但似乎过分了.

I could use .Rprofile to run R codes every time I start R, so I could just update versions whenever I start R (or build in that it only updates the version if the date is not today or something) but that seems overdoing it.

您可以为每个项目创建一个单独的 .Rprofile.你必须把它放在项目的主目录中(http://www.rstudio.txt).com/ide/docs/using/projects).

You can make a separate .Rprofile for each project. You have to put it in the main directory of the project (http://www.rstudio.com/ide/docs/using/projects).