Changing R library path
I’ve been using R to do data analysis for process improvement for some time now. I’ve learned so much in the past year that I want to write many posts in a specific order, but they end up being kept in my mind. That’s no good. This year, I’ve decided to start posting every little new thing I learn in no particular order. Even if it’s simple, if I’ve just learned it, I’ll share it.
So, here is my most recent problem:
I use R Studio in a corporate machine in which I’m not the admin. There, the packages were installed in a temporary folder that is cleaned from time to time. I didn’t pay attention to that until the packages were deleted and I was blocked on re-installing them. I had to repair the application from time to time. And today, I got a new warning stating that the library was not writable.
install.packages("lubridate")
Installing package into 'C:/Users/Public/R/libraries_i386'
(as 'lib' is unspecified)
Warning in install.packages :
'lib = "C:/Users/Public/R/libraries_i386"' is not writable
I thought the best would be just to install the packages in a local folder that I have control over. So, I’ve added a new library to my library path.
> .libPaths( c( .libPaths(), "H:/My Documents/data analysis/R") )
> .libPaths()
[1] "C:/Users/Public/R/libraries_i386"
"Q:/RSTUD301.001/R-3.2.2/library" "H:/My Documents/data analysis/R"
Alternatively, if you just add a new path:
.libPaths("H:/My Documents/data analysis/R")
.libPaths()
The .libPaths function adds the new one as the first path to be used:
[1] "H:/My Documents/data analysis/R" "Q:/RSTUD301.001/R-3.3.1/library"
Now, every time I install a package, I select my local folder and the packages will not be deleted.
Source in StackOverflow.
Recent Posts
-
The Science of Choice
-
Rolling out Enterprise Architecture
-
7 Steps to Create Processes
-
First thoughts on Prediction Machines
-
The woman I am
-
Becoming a Runner
-
Business Process Overview
-
How to link Business Rules with Business Objects
-
Analysing Open Data from the Canadian Government with Python
-
Analysis of an Infographic according to Alberto Cairo's mechanisms
-
Git: How to know if your directory is already under version control?
-
Shiny Application to analyse graduates per country and year
-
I don’t like boxes, do you?!
-
Need a solution to integrate a BPM and IT