[R] Automatic detachment of dependent packages

Gabor Grothendieck ggrothendieck at gmail.com
Fri Sep 7 17:18:45 CEST 2007


If its good enough just to get rid of all attached packages since after startup
you could just do repeated detaches like this making use of the fact that
search() has 9 components on startup:

replicate(length(search()) - 9, detach())


On 9/7/07, Paul Smith <phhs80 at gmail.com> wrote:
> Dear All,
>
> When one loads certain packages, some other dependent packages are
> loaded as well. Is there some way of detaching them automatically when
> one detaches the first package loaded? For instance,
>
> > library(sqldf)
> Loading required package: RSQLite
> Loading required package: DBI
> Loading required package: gsubfn
> Loading required package: proto
>
> but
>
> > detach(package:sqldf)
> >
> > search()
>  [1] ".GlobalEnv"        "package:gsubfn"    "package:proto"
>  [4] "package:RSQLite"   "package:DBI"       "package:stats"
>  [7] "package:graphics"  "package:grDevices" "package:utils"
> [10] "package:datasets"  "package:methods"   "Autoloads"
> [13] "package:base"
>
> The packages
>
> RSQLite
> DBI
> gsubfn
> proto
>
> were not detached.
>
> Thanks in advance,
>
> Paul
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list