Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove all packages that do not come with R

Tags:

How can I remove all installed packages except base and recommended?

like image 606
ECII Avatar asked May 05 '13 08:05

ECII


People also ask

How do I completely uninstall a package in R?

From the R terminal enter the command remove. packages("package-to-remove") to remove or uninstall the package from R environment.

How do you list all R packages installed?

To see what packages are installed, use the installed. packages() command. This will return a matrix with a row for each package that has been installed.


2 Answers

Be CAREFUL! And read the docs before you try this:

# Pasted as a commented to prevent blindly copying and pasting # remove.packages( installed.packages( priority = "NA" )[,1] ) 

By default this will remove packages from the first library in your .libPaths().

like image 179
Simon O'Hanlon Avatar answered Oct 17 '22 07:10

Simon O'Hanlon


Instead of

Updated to R 3.0.0 and have to rebuild all packages.

just do

update.packages(..., checkBuilt=TRUE) 

which is what I did on my R 3.0.0 (using lib.loc=... to point to my different local directories). This will update everything you have and which it can still get from repos such as CRAN. For install_git() etc, you are out of luck and need to reinstall.

But either way you do not need to remove the packages first.

like image 34
Dirk Eddelbuettel Avatar answered Oct 17 '22 07:10

Dirk Eddelbuettel