5

Actual question

Can I unload and remove a package without having to restart an R process that has already required/loaded the package?

I've had a look at this question/answer, but it only deals with part of the problem (unloading)


Background

The reason I want to do this is that I am working on a project-based framework for package development in which I'm also using project-based package libraries in order to keep the standard library "clean" and allow for systematic testing of package dependencies.

The only problem with this is that it's really hard for the user to remember the path to a project-based package library before initializing the project (which also loads all specified package dependencies via require() and makes the project-based library the first one in .libPaths())

Practically, this means that a user currently can't really uninstall a package dependency from the project-based package library in a comfortable way (after initializing the project, that is) and I'm looking for ways to change this.

What I tried

install.packages("forecast")
require("forecast")

detach("package:forecast", unload=TRUE)
remove.packages("forecast")

> install.packages("forecast")
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.15
trying URL 'http://cran.rstudio.com/bin/windows/contrib/2.15/forecast_4.03.zip'
Content type 'application/zip' length 1124001 bytes (1.1 Mb)
opened URL
downloaded 1.1 Mb

package 'forecast' successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package 'forecast'

The downloaded binary packages are in
    C:\Users\wwa418\AppData\Local\Temp\RtmpYPry89\downloaded_packages

The problem seems to be /forecast/libs/i386/forecast.dll which probably gets registered upon loading and seems to be a tough one to kill ;-)

Any ideas?

Community
  • 1
  • 1
Rappster
  • 12,762
  • 7
  • 71
  • 120

0 Answers0