Automatically run R code when opening an RStudio project

I wrote an R function that updates the package version number in another question . I work a lot with GitHub and RStudio, and this will provide me with enough time (plus will be much more accurate) if this function is automatically launched every time I open a certain project (or, even better, I do git commit / push, but I assume that is harder to do). But I do not know how to do this or if it is possible.

I could use .Rprofile to run R codes every time R starts, so I could just update versions whenever I run R (or make sure it only updates the version if the date is not today or something- something else) but it seems excessive.

+8
r rstudio
source share
2 answers

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

+6
source share

Well, I would use .Rprofile for this. There is something to say that you are not dependent on the tool chain around you: knitr works from RStudio, as well as without it, dito for Rcpp / RInside, etc.

You can connect to commit commit for svn, either explicitly using hooks at the end, or just adding shell scripts in the end. I suppose you can do the same with git, but I just know a lot less about that. Therefore, in order to distract this, I will write myself a commitThis or pushThis or ... function, which will increase the number, test run, code writing and what you have.

+4
source share

All Articles