R not picking up user library
If you have a ~/.Renviron
, it might overwrite things. And if you have a ~/.Rprofile
which does a call to .libPaths
with a non-existant directory you will have neither of them in your search path.
R not finding package even after package installation
Do .libPaths()
, close every R runing, check in the first directory, remove the zoo
package restart R and install
zoo
again. Of course you need to have sufficient rights.
RStudio can't find my library on startup
I decided to start clean, I re-installed both R and RStudio and deleted my old library.
A risky option is running R (or RStudio) as an administrator---this allowed me to install into the default library, which avoids the problems of using a separate library.
In newer versions of RStudio I've had no problems using a separate library, specifying the site library in my Rprofile.site file.
Change R default library path using .libPaths in Rprofile.site fails to work
I generally try to keep all of my packages in one library, but if you want to add a library why not append the new library (which must already exist in your filesystem) to the existing library path?
.libPaths( c( .libPaths(), "~/userLibrary") )
# obviously this would need to be a valid file directory in your OS
# min just happened to be on a Mac that day
Or (and this will make the userLibrary the first place to put new packages):
.libPaths( c( "~/userLibrary" , .libPaths() ) )
Then I get (at least back when I wrote this originally):
> .libPaths()
[1] "/Library/Frameworks/R.framework/Versions/2.15/Resources/library"
[2] "/Users/user_name/userLibrary"
The .libPaths
function is a bit different than most other nongraphics functions. It works via side-effect. The functions Sys.getenv
and Sys.setenv
that report and alter the R environment variables have been split apart but .libPaths
can either report or alter its target.
The information about the R startup process can be read at ?Startup
help page and there is RStudio material at: https://support.rstudio.com/hc/en-us/articles/200549016-Customizing-RStudio
In your case it appears that RStudio is not respecting the Rprofile.site settings or perhaps is overriding them by reading an .Rprofile setting from one of the RStudio defaults. It should also be mentioned that the result from this operation also appends the contents of calls to .Library
and .Library.site
, which is further reason why an RStudio- (or any other IDE or network installed-) hosted R might exhibit different behavior.
Since Sys.getenv()
returns the current system environment for the R process, you can see the library and other paths with:
Sys.getenv()[ grep("LIB|PATH", names(Sys.getenv())) ]
The two that matter for storing and accessing packages are (now different on a Linux box):
R_LIBS_SITE /usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library
R_LIBS_USER /home/david/R/x86_64-pc-linux-gnu-library/3.5.1/
Related Topics
Convert 12Hour Time to 24Hour Time
R Applying a Function to a Subset of a Data Frame
R Package Conflict Between Gam and Mgcv
Grouped Bar Chart on R Using Ggplot2
Using Read.Csv.Sql to Select Multiple Values from a Single Column
R Finding Duplicates in One Column and Collapsing in a Second Column
How to Extract Coefficients' Standard Error from an "Aov" Model
Axis-Labeling in R Histogram and Density Plots; Multiple Overlays of Density Plots
Get Plot() Bounding Box Values
Arrange Within a Group with Dplyr
How to Get All Possible Combinations of N Number of Data Set
Ggplot2: How to Separate Geom_Polygon and Geom_Line in Legend Keys
Leaflet Not Rendering in Dynamically Generated R Markdown HTML Knitr
Data Table String Concatenation of Sd Columns for by Group Values