Dependency management in R

前端 未结 4 1178
野趣味
野趣味 2021-02-02 16:26

Does R have a dependency management tool to facilitate project-specific dependencies? I\'m looking for something akin to Java\'s maven, Ruby\'s bundler, Python\'s virtualenv, No

4条回答
  •  逝去的感伤
    2021-02-02 16:45

    You could use the following workflow:

    1) create a script file, which contains everything you want to setup and store it in your projectd directory as e.g. projectInit.R

    2) source this script from your .Rprofile (or any other file executed by R at startup) with a try statement

    try(source("./projectInit.R"), silent=TRUE)
    

    This will guarantee that even when no projectInit.R is found, R starts without error message

    3) if you start R in your project directory, the projectInit.R file will be sourced if present in the directory and you are ready to go

    This is from a Linux perspective, but should work in the same way under windows and Mac as well.

提交回复
热议问题