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

后端 未结 15 2835
青春惊慌失措
青春惊慌失措 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:11

    Since most of the answers here are related to Windows & Mac OS, (and considering that I also struggled with this) I decided to post the process that helped me solve this problem on my Arch Linux setup.

    Step 1:

    • Do a global search of your system (e.g. ANGRYSearch) for the term Renviron (which is the configuration file where the settings for the user libraries are set).
    • It should return only two results at the following directory paths:
      1. /etc/R/
      2. /usr/lib/R/etc/
        NOTE: The Renviron config files stored at 1 & 2 (above) are hot-linked to each other (which means changes made to one file will automatically be applied [ in the same form / structure ] to the other file when the file being edited is saved - [ you also need sudo rights for saving the file post-edit ] ).

    Step 2:

    • Navigate into the 1st directory path ( /etc/R/ ) and open the Renviron file with your favourite text editor.
    • Once inside the Renviron file search for the R_LIBS_USER tag and update the text in the curly braces section to your desired directory path.

      EXAMPLE:
      ... Change From ( original entry ):
      R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/4.0'}
      ... Change To ( your desired entry ):
      R_LIBS_USER=${R_LIBS_USER-'~/Apps/R/rUserLibs'}

    Step 3:

    • Save the Renviron file you've just edited ... DONE !!

提交回复
热议问题