% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/run_covr_modes.R
\name{load_base_r_packages_into_env}
\alias{load_base_r_packages_into_env}
\title{Load Base R packages into an isolated coverage environment}
\usage{
load_base_r_packages_into_env(env, overwrite = FALSE)
}
\arguments{
\item{env}{An environment to populate.}

\item{overwrite}{Logical; if `TRUE`, overwrite objects already present in
`env`. If `FALSE` (default), existing objects are left unchanged.}
}
\value{
A named list with two character vectors:
\describe{
  \item{exports_loaded}{Exported objects copied from Base R packages
  other than `base` and `datasets`.}
  \item{datasets_loaded}{Dataset objects loaded from the `datasets`
  package.}
}
}
\description{
Populate an isolated environment (typically created with
`new.env(parent = baseenv())`) with objects needed to mimic the
standard Base R package surface during coverage or test evaluation.
}
\details{
The `base` package itself is already available via `baseenv()` and is
therefore not copied into `env`. The function instead:

- loads datasets from the `datasets` package into `env`, and
- copies exported objects from other Base R packages into `env`
  (e.g. `stats`, `utils`, `graphics`, `grDevices`, `methods`, etc.).

This is useful when tests are evaluated in a deliberately isolated
environment whose parent is `baseenv()`, because objects from packages
such as `stats` (e.g. `rnorm`) and `datasets` (e.g. `mtcars`, `iris`)
are not automatically visible there.


The Base R package set handled here is:
\itemize{
  \item `base`
  \item `compiler`
  \item `datasets`
  \item `graphics`
  \item `grDevices`
  \item `grid`
  \item `methods`
  \item `parallel`
  \item `splines`
  \item `stats`
  \item `stats4`
  \item `tcltk`
  \item `tools`
  \item `utils`
}

Because `base` is already reachable through `baseenv()`, it is excluded
from the explicit copy step.
}
\keyword{internal}
