0

i have two library path how can I override that via an argument to both install.packages() (from inside R) or R CMD INSTALL (outside R).

or override by setting the R_LIBS_USER variable.

knzy
  • 1
  • What exactly is your current configuration? There are usually two paths. The first is normally a user specific path which is the default, and the second is the path where the base packages go. Usually those are kept separate. The R_LIBS_USER variable will just change the path for the first. You could write a custom `?Startup` script if you want to change the values each time you run R. Or maybe you want more of an environment set up type situation, if so look into the `renv` package. – MrFlick Mar 27 '22 at 06:16
  • The details in ?Startup should be reviewed. – IRTFM Mar 27 '22 at 06:16
  • i really cannot understand your comment, so what I meant when i type .libpath() i got two different paths one set by defalt so is having two ddifferent paths would affect my coding when i install packages shouldnot I have one path only for libpath or no – knzy Mar 27 '22 at 07:36

1 Answers1

1

The usual reason to end up with two libraries is that the system library is not writable when you install new packages.

So if you only want one path in .libPaths(), always run with elevated permissions ("Run as administrator" on Windows, use sudo on others) when you install packages.

It's probably a better idea not to install packages in the system library other than the base packages that come with R, because it's very easy to forget to change privileges, and then you can end up with two libraries again, and have one version of a package in the system library and a different version in the user library.

user2554330
  • 37,248
  • 4
  • 43
  • 90