Rstudio is another library path to the R command line (`$ R_LIBS_USER`)

I am trying to understand why my .libPath is different between the R command line and RStudio Desktop (NOTE: this is not a duplicate of this question , since this fix is ​​related to material specific to RStudio Server that I do not have).

When I use R on the command line (linux):

 > .libPaths() [1] "/home/mathematicalcoffee/R/library" "/usr/local/lib/R/site-library" [3] "/usr/lib/R/site-library" "/usr/lib/R/library" 

When I use RStudio Desktop (linux, same computer):

 [1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library" "/usr/lib/R/library" "/usr/lib/rstudio/R/library" 

Now I set $R_LIBS_USER to ~/R/library in my bash profile, so R-command-line selects it as my preferred libPath.

The problem is in RStudio Desktop when I do this:

 Sys.getenv('R_LIBS_USER') # "~/R/x86_64-pc-linux-gnu-library/2.15" 

So why did RStudio Desktop change my R_LIBS_USER ? How can i change it? (I do not use the .Rprofile file). (In the question I linked above, the solution for RStudio Server was to change /etc/rstudio/rsession.conf , but I don’t have it, because I have RStudio Desktop. In addition, I believe that RStudio should respect my variable environment R_LIBS_USER ).

+7
source share
1 answer

You write:

Now I set $ R_LIBS_USER to the library ~ / R / in my bash profile,

Do you accidentally call RStudio from the gui icon, that is, without calling your ~/.bash_profile ? Maybe you can try calling a shell instead of it that installs it?

For what it costs, .libPaths() returns the same in RStudio Desktop and Server (although the server adds its own internal directory), R on the command line and through ESS for me.

Edit: In general, read the help(Startup) , which will be spent on time. Comment @flodel is quite appropriate. If you lose work with this at the system level, you can always switch to R at the system level (via Renviron and Renviron.site ) or through the ~/R/ directory.

+9
source

All Articles