Change R default library path using .libPaths in Rprofile.site fails to work

后端 未结 15 3014
青春惊慌失措
青春惊慌失措 2020-11-22 06:27

I am running R on Windows, not as an administrator. When I install a package, the following command doesn\'t work:

> install.packages(\"zoo\")
Installing          


        
15条回答
  •  面向向阳花
    2020-11-22 07:05

    I managed to solve the problem by placing the code in the .Rprofile file in the default working directory.

    First, I found the location of the default working directory

    > getwd()
    [1] "C:/Users/me/Documents"
    

    Then I used a text editor to write a simple .Rprofile file with the following line in it

    .libPaths("C:/software/Rpackages")
    

    Finally, when I start R and run .libPaths() I get the desired output:

    > .libPaths()
    [1] "C:/software/Rpackages"               "C:/Program Files/R/R-2.15.2/library"
    [3] "C:/Program Files/RStudio/R/library"
    

提交回复
热议问题