load_all: Load All Package Code

View source: R/dev.R

load_allR Documentation

Load All Package Code

Description

Sources all R files in a package for interactive development, without requiring a full install.

Usage

load_all(path = ".", env = new.env(parent = globalenv()), quiet = TRUE)

Arguments

path

Path to package root directory.

env

Environment to source files into. Defaults to a fresh environment whose parent is the global environment.

quiet

Logical. Suppress file sourcing messages? Default TRUE.

Value

The environment into which files were sourced (invisibly). Does not modify the search path. If you want search-path behavior, call 'attach()' yourself:

attach(tinypkgr::load_all(), name = "tinypkgr:mypkg")

See Also

kitten for scaffolding a new package.

Examples

# Scaffold a throwaway package in tempdir() and source its R/ files.
pkg <- file.path(tempdir(), "loadpkg")
dir.create(file.path(pkg, "R"), recursive = TRUE, showWarnings = FALSE)
writeLines(c(
  "Package: loadpkg",
  "Title: Example",
  "Version: 0.0.1",
  "Authors@R: person('A', 'B', email = 'a@b.com', role = c('aut','cre'))",
  "Description: Example.",
  "License: GPL-3"
), file.path(pkg, "DESCRIPTION"))
writeLines("add <- function(x, y) x + y", file.path(pkg, "R", "add.R"))

e <- load_all(pkg)
e$add(2, 3)

unlink(pkg, recursive = TRUE)

tinypkgr documentation built on April 22, 2026, 9:07 a.m.