11

Possible Duplicate:
How to unload a package without restarting R?

To load a package into R we can go library(.) or require(.). How do I disable a package during a coding session. I want something that's the opposite of require(.).

Community
  • 1
  • 1
Jase
  • 1,025
  • 1
  • 9
  • 34

1 Answers1

12

I think maybe you're looking for detach(package:splines, unload = TRUE).

As you might gather from the comments below, be sure to read carefully the Details section of ?detach to make sure you know exactly what will happen when using this with or without the unload and force arguments.

joran
  • 169,992
  • 32
  • 429
  • 468
  • 2
    note that with complicated packages that load S4 classes & methods, this unloading is not *guaranteed* to restore everything to exactly the state before the package was loaded. (There's discussion on r-devel somewhere I think ...) – Ben Bolker Jan 03 '13 at 16:31
  • 1
    In particular, if the package supplies any S3 methods whose generic is from another package, those methods won't be removed by any `detach()` call ([example here](http://stackoverflow.com/questions/11004018/how-can-a-non-imported-method-in-a-not-attached-package-be-found-by-calls-to-fun) in kohske's answer). (I'd love to know if there are any other classes of objects that can be left lying around by `detach()`.) – Josh O'Brien Jan 03 '13 at 18:05