How to unload a package without restarting R
Asked 07 September, 2021
Viewed 2.6K times
  • 57
Votes

I'd like to unload a package without having to restart R (mostly because restarting R as I try out different, conflicting packages is getting frustrating, but conceivably this could be used in a program to use one function and then another--although namespace referencing is probably a better idea for that use).

?library doesn't show any options that would unload a package.

There is a suggestion that detach can unload package, but the following both fail:

detach(vegan)

  

Error in detach(vegan) : invalid name argument

detach("vegan")

  

Error in detach("vegan") : invalid name argument

So how do I unload a package?

name
Answer

12 Answer