Safely removes a specified R package and its unused dependencies from the system, ensuring that other installed packages do not lose required dependencies.
Value
A character vector of the packages that were removed, or invisibly `character()` if nothing was removed.
Details
The function implements a dependency-aware removal process:
Identifies the dependencies of the target package using `tools::package_dependencies`.
Analyzes all other installed packages to determine which dependencies are still required.
Isolates "orphan" dependencies—those that were only required by the target package.
Interactively prompts the user to select which of these orphan packages (and the target package itself) should be removed.
Executes `remove.packages()` on the selected items.
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_package('curl')
}
