[R-SIG-Mac] Local level packages not in path

Kasper Daniel Hansen khansen at stat.Berkeley.EDU
Tue Apr 24 05:53:06 CEST 2007


On Apr 23, 2007, at 7:35 PM, James wrote:

> Hi,
>
> I'm completely new to R and it's usage on a Mac.  I'm having a bit of
> trouble installing packages through the Package Installer interface
> in R.app.  I'm trying to install the group of Rmetrics packages for
> option pricing.  When doing so, I'm given the choice of installing at
> the "System Level" or the "Local Level".  I chose to install at the
> local level.  The packages appear to have been correctly installed to
> ~/Library/R/library/.  The problem appears to be that the location is
> not in my path.
>
>> .libPath()
> [1] "/Library/Frameworks/R.framework/Versions/2.4/Resources/library"
>
> So system level packages are available, but not local level
> packages.  I see under preferences for R.app, under Startup, the
> ability to set the "Default Library Paths".  There is a check box to
> "Add $HOME/R/Library".  Is this what I need to set to get my local
> level packages added to my path?  Additionally, it says that I have
> to restart R.app for this to take effect.  When I restart, the box is
> unchecked again.  Do I have to save my workspace to get this setting
> set?

The workspace has nothing to do with it. The setting should work, but  
I seem to recall a problem a long time ago with making R remember it.  
Perhaps other users can help here.

> And finally, is there just a text file or something that I could edit
> to make this addition?  It seems like those persons not using R.app,
> namely everyone on Linux, Windows, and some Mac users would need a
> way to set this.

There are various ways. The best is probably to use
~/.Rprofile
which is an R script executed when you start R. In your case it  
should contain something like
.libPaths("~/Library/R/library")

You can also use the environment variable
   R_LIBS
but that is more problematic to set for a GUI, or you can use the file
~/.Renviron
for setting a collection of environment variables, but these  
variables are not used when you do
R CMD BATCH
which I personally find irritating, but I assume there is a use case.

Kasper

> Thank you for any help you can provide.
>
> James
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac



More information about the R-SIG-Mac mailing list