
Remove User-Installed Packages
Source:R/remove_user_installed_packages.R
remove_user_installed_packages.RdIdentifies and removes all user-installed R packages from the system, while carefully preserving base and recommended packages, as well as packages installed in specific system libraries (e.g., MRO).
Value
Invisibly returns a named list with components: status ("done" or
"clean") and packages_removed (character vector).
Details
The function performs the following steps:
Retrieves a list of all installed packages.
Filters out packages located in libraries containing "MRO" to avoid corrupting system-specific installations.
Filters out packages with a priority of "base" or "recommended" to ensure core R functionality remains intact.
Identifies the library paths where the remaining user packages are installed.
Iteratively removes each identified user package using `remove.packages()`.
Warning
This function modifies files on disk or the global environment. Please ensure you have a backup or are using version control (e.g., Git) before execution.
Examples
if (interactive()) {
remove_user_installed_packages()
}