Try this using ?detach:
detach("package:ans", unload=TRUE)
Alternatively you can also use unloadNamespace command
unloadNamespace("ans")
For multiple versions of a package loaded at once use
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)
}
}
In your case either use
detach_package(ans)
or use
detach_package("ans", TRUE)
Thank you for reading this answer.