Unload a package without restarting R

0 votes

I want to unload a package without restarting R

I tried using ?library, but it does not show options that would unload a package.

Then, I tried using detach that can unload a package.
But it failed and shows an error:

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

Any suggestions to unload the package?

Apr 17, 2018 in Data Analytics by darklord
• 6,140 points
165 views

1 answer to this question.

0 votes

Try the below option:

detach("package:vegan", unload=TRUE)

NOTE: You can try ?detach for details on detach

Multiple versions of a package can be loaded once.

To guarantee that all copies are detached, use the below function:

detach_package <- function(abcpkg, character.only = FALSE)
{
  if(!character.only)
  {
    abcpkg <- deparse(substitute(abcpkg))
  }
  search_item <- paste("package", abcpkg, sep = ":")
  while(search_item %in% search())
  {
    detach(search_item, unload = TRUE, character.only = TRUE)
  }
}

If you want to use detach for a single package, then, use the below options:

detach_package(vegan)

OR

detach_package("vegan", TRUE)
answered Apr 17, 2018 by DataKing99
• 8,130 points

Related Questions In Data Analytics

0 votes
1 answer

Unload package without restarting R

You can use the unloadNamespace command, as ...READ MORE

answered Nov 5, 2018 in Data Analytics by Kalgi
• 40,440 points
20 views
0 votes
1 answer

How can I import a file in R without giving the destination/file path to the specified file?

You can use the window explorer to ...READ MORE

answered Aug 28, 2018 in Data Analytics by Anmol
• 3,620 points

edited Aug 28, 2018 by Vardhan 46 views
0 votes
1 answer
0 votes
1 answer

How to install an R package from source?

If you have your file located locally ...READ MORE

answered Apr 13, 2018 in Data Analytics by CodingByHeart77
• 3,680 points
50 views
0 votes
1 answer

Is there any way to check for missing packages and install them in R?

There are 2 options: Either you can use ...READ MORE

answered Apr 17, 2018 in Data Analytics by nirvana
• 3,060 points
43 views
0 votes
1 answer

Unable to install the 'devtools' package in R

Run the below command in your Ubuntu/Linux ...READ MORE

answered Jun 6, 2018 in Data Analytics by Bharani
• 4,550 points
571 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 17, 2017 in Data Analytics by Sudhir
• 1,610 points
47 views
0 votes
1 answer

How to filter a data frame with dplyr and tidy evaluation in R?

Requires the use of map_df to run each model, ...READ MORE

answered May 16, 2018 in Data Analytics by DataKing99
• 8,130 points
92 views
0 votes
1 answer

How to evaluate expression given as a string in R?

The eval() function evaluates an expression, but "5+5" is a string, ...READ MORE

answered Jun 7, 2018 in Data Analytics by DataKing99
• 8,130 points
135 views