How to unload a package without restarting R
Try this (see ?detach
for more details):
detach("package:vegan", unload=TRUE)
It is possible to have multiple versions of a package loaded at once (for example, if you have a development version and a stable version in different libraries). To guarantee that all copies are detached, use this function.
detach_package <- function(pkg, character.only = FALSE)
{
if(!character.only)
{
pkg <- deparse(substitute(pkg))
}
search_item <- paste("package", pkg, sep = ":")
while(search_item %in% search())
{
detach(search_item, unload = TRUE, character.only = TRUE)
}
}
Usage is, for example
detach_package(vegan)
or
detach_package("vegan", TRUE)
How to disable package without restarting R?
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.
Can Rcpp package DLLs be unloaded without restarting R?
If you want to do this in your main R session (without using RStudio, which makes reinstalling the package and reloading R very easy), you can use devtools:
library(devtools)
load_all("path/to/my/package")
Among other things, load_all
will reload all your R code, and re-compile and reattach the DLL.
How to detach a package without restarting
You cannot detach a package that is already loaded in some module AFAICT. What you can do is wrap your code using these methods in a module like this:
module Test1
using PackageOne
some_method()
end
module Test2
using PackageTwo
some_method()
end
another approach would be:
using PackageOne
using PackageTwo
methods = [PackageOne.some_method, PackageTwo.some_method]
function test(some_method)
# here use some_method
end
for method in methods
test(method)
end
Related Topics
Dplyr Mutate Rowsums Calculations or Custom Functions
Create a Data.Frame Where a Column Is a List
Number of Months Between Two Dates
Reshape Multiple Values At Once
Idiomatic R Code For Partitioning a Vector by an Index and Performing an Operation on That Partition
How to Convert Long to Wide Format With Counts
Yaml Current Date in Rmarkdown
Basic Lag in R Vector/Dataframe
Replace Missing Values With Column Mean
Plotting Lines and the Group Aesthetic in Ggplot2
Frequency Count of Two Column in R
How to Perform Natural (Lexicographic) Sorting in R
What's Wrong With My Function to Load Multiple .Csv Files into Single Dataframe in R Using Rbind