How to load packages automatically when opening a project in RStudio

后端 未结 2 1362
逝去的感伤
逝去的感伤 2021-02-07 11:51

Every time I restart RStudio-it requires me to reload all of the packages that were loaded in the workspace previously. I can\'t seem to figure out what the problem is, RStudio

2条回答
  •  一个人的身影
    2021-02-07 12:20

    I presume you want to say that you have to reload all of the packages that were loaded in the workspace previously. That's not an error, that's by design.

    If you want to load some packages at startup in a project, you can do so by creating a file called .Rprofile in the project directory, and specify whatever code you want RStudio to run when loading the project.

    For example:

    cat("Welcome to this project.\n")
    require(ggplot2)
    require(zoo)
    

    would print a welcome message in the console, and load ggplot2 and zoo every time you open the project.

    See also http://www.rstudio.com/ide/docs/using/projects

提交回复
热议问题