Skip to main content
edited tags; edited title
Link
zx8754
  • 55.3k
  • 12
  • 123
  • 220

Changing Change R default library path using .libPaths in Rprofile.site fails to work

Question Protected by zx8754
edited tags
Link
IRTFM
  • 262.3k
  • 22
  • 372
  • 493
Added the output for install.packages("zoo") that doesn't work
Source Link
I Like to Code
  • 7.2k
  • 13
  • 40
  • 49

I am running R on Windows, not as an administrator. When I install a package, the following command doesn't work:

> install.packages("zoo")
Installing package(s) into ‘C:/Program Files/R/R-2.15.2/library’
(as ‘lib’ is unspecified)
Warning in install.packages :
  'lib = "C:/Program Files/R/R-2.15.2/library"' is not writable

To install a package, I have to specify a library location:

install.packages("zoo", lib="C:/software/Rpackages")

To load a package, I also have to specify the library location:

library("zoo", lib.loc="C:/software/Rpackages")

All of this is OK, but I wanted to see if I could add C:/software/Rpackages to the library path somehow and thus not have to type it each time.

As I searched online, I found that one way to do this is to edit the Rprofile.site file and to add the line

.libPaths("C:/software/Rpackages")

However, after doing this, and starting RStudio, this is the output that I get

> .libPaths()
[1] "C:/Program Files/R/R-2.15.2/library" "C:/Program Files/RStudio/R/library" 

The .libPaths command that I added to the Rprofile.site doesn't seem to have had any effect! Why is this the case? Or more importantly, how can I fix the problem so that I can install and load packages without typing in the library location?

Note: if I start RStudio the .libPaths() command seems to work as it is supposed to

.libPaths("C:/software/Rpackages")
> .libPaths()
[1] "C:/software/Rpackages"               "C:/Program Files/R/R-2.15.2/library"

Isn't that strange?

I am running R on Windows, not as an administrator. When I install a package, the following command doesn't work:

install.packages("zoo")

To install a package, I have to specify a library location:

install.packages("zoo", lib="C:/software/Rpackages")

To load a package, I also have to specify the library location:

library("zoo", lib.loc="C:/software/Rpackages")

All of this is OK, but I wanted to see if I could add C:/software/Rpackages to the library path somehow and thus not have to type it each time.

As I searched online, I found that one way to do this is to edit the Rprofile.site file and to add the line

.libPaths("C:/software/Rpackages")

However, after doing this, and starting RStudio, this is the output that I get

> .libPaths()
[1] "C:/Program Files/R/R-2.15.2/library" "C:/Program Files/RStudio/R/library" 

The .libPaths command that I added to the Rprofile.site doesn't seem to have had any effect! Why is this the case? Or more importantly, how can I fix the problem so that I can install and load packages without typing in the library location?

Note: if I start RStudio the .libPaths() command seems to work as it is supposed to

.libPaths("C:/software/Rpackages")
> .libPaths()
[1] "C:/software/Rpackages"               "C:/Program Files/R/R-2.15.2/library"

Isn't that strange?

I am running R on Windows, not as an administrator. When I install a package, the following command doesn't work:

> install.packages("zoo")
Installing package(s) into ‘C:/Program Files/R/R-2.15.2/library’
(as ‘lib’ is unspecified)
Warning in install.packages :
  'lib = "C:/Program Files/R/R-2.15.2/library"' is not writable

To install a package, I have to specify a library location:

install.packages("zoo", lib="C:/software/Rpackages")

To load a package, I also have to specify the library location:

library("zoo", lib.loc="C:/software/Rpackages")

All of this is OK, but I wanted to see if I could add C:/software/Rpackages to the library path somehow and thus not have to type it each time.

As I searched online, I found that one way to do this is to edit the Rprofile.site file and to add the line

.libPaths("C:/software/Rpackages")

However, after doing this, and starting RStudio, this is the output that I get

> .libPaths()
[1] "C:/Program Files/R/R-2.15.2/library" "C:/Program Files/RStudio/R/library" 

The .libPaths command that I added to the Rprofile.site doesn't seem to have had any effect! Why is this the case? Or more importantly, how can I fix the problem so that I can install and load packages without typing in the library location?

Note: if I start RStudio the .libPaths() command seems to work as it is supposed to

.libPaths("C:/software/Rpackages")
> .libPaths()
[1] "C:/software/Rpackages"               "C:/Program Files/R/R-2.15.2/library"

Isn't that strange?

Source Link
I Like to Code
  • 7.2k
  • 13
  • 40
  • 49
Loading