% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/package-remover.R
\name{remove_package}
\alias{remove_package}
\title{Interactive Package Remover}
\usage{
remove_package(pkg, recursive = FALSE)
}
\arguments{
\item{pkg}{Character. The name of the package to remove.}

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