Facing the very same problem (avoiding the default path in a network) I came up to this solution with the hints given in other answers.
The solution is editing the Rprofile
file to overwrite the variable R_LIBS_USER
which by default points to the home directory.
Here the steps:
~\target
.Rprofile
file. In my case it was at C:\Program Files\R\R-3.3.3\library\base\R\Rprofile
.R_LIBS_USER
. In my case, I replaced the this line file.path(Sys.getenv("R_USER"), "R",
with file.path("~\target", "R",
.The documentation that support this solution is here
Original file with:
if(!nzchar(Sys.getenv("R_LIBS_USER")))
Sys.setenv(R_LIBS_USER=
file.path(Sys.getenv("R_USER"), "R",
"win-library",
paste(R.version$major,
sub("\\..*$", "", R.version$minor),
sep=".")
))
Modified file:
if(!nzchar(Sys.getenv("R_LIBS_USER")))
Sys.setenv(R_LIBS_USER=
file.path("~\target", "R",
"win-library",
paste(R.version$major,
sub("\\..*$", "", R.version$minor),
sep=".")
))