[R] Preventing loading of user packages

David Winsemius dwinsemius at comcast.net
Mon Aug 25 21:59:02 CEST 2014


On Aug 25, 2014, at 7:11 AM, Ista Zahn wrote:

> On Mon, Aug 25, 2014 at 5:58 AM, Jonathon Love <jon at thon.cc> wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA512
>> 
>> Hi,
>> 
>> I'm trying to prevent the loading of packages from the 'personal
>> library'
> 
> Of behalf of the users you are about to cripple, please, do not do that!

Hello jonathon and Ista;

(I think this might be the first time I've seriously with Ista.) I've been in the situation where I had multiple copies of packages in 2 different libraries and wanted to do exactly what was requested. I'm assuming that the "main" library directory is something other than '~/Library/R/3.0/library' and permissions allow packages to be accessed and placed there. A quick method would simply be to execute this at the command line (or if it needed to be repeated in .Rprofile) :

.libPaths( .libPaths()[!which(.libPaths() == '~/Library/R/3.0/library')] )

I suppose you could wrap some testing around this to prevent the removal of that path if it were the only one or if it were the path to the base and stats packages. Fo me this reports correctly that my base package is not there:

> grepl("~/Library/R/3.0/library" , attr(packageDescription('base'), "file") )
[1] FALSE

But this raises the question. Why is this happening and why don't you just delete the directory?

-- 
David.

> 
> -Ista
> 
> on an OS X machine. i.e. the packages that are normally
>> placed somewhere like:
>> 
>> ~/Library/R/3.0/library
>> 
>> There is a file in the R.framwork directory:
>> 
>> /Versions/3.0/Resources/etc/Renviron
>> 
>> which contains a line:
>> 
>> R_LIBS_USER=${R_LIBS_USER-'~/Library/R/3.0/library'}
>> 
>> but commenting this out does not prevent R from loading from that
>> location.
>> 
>> is there a way to prevent loading from that location?
>> 
>> with thanks
>> 
>> jonathon
>> 
>> - --
>> 


David Winsemius
Alameda, CA, USA



More information about the R-help mailing list