MyNixOS website logo
Description

Annotate Package Load Calls.

Provides non-invasive annotation of package load calls such as \code{library()}, \code{p_load()}, and \code{require()} so that we can have an idea of what the packages we are loading are meant for.

annotater

CRANstatus Codecov testcoverage

The goal of annotater is to annotate package load calls in character strings and R/Rmd files, so we can have an idea of the overall purpose of the libraries we’re loading.

What do my loaded packages do?

Where did I get them?


The two annotation types are also available together:

Thanks to Juan Cruz Rodriguez, we can now annotate which functions from each package are being called in a script.

As of version 0.2.3, loaded datasets can also be added as annotations.

pacman compatibility

Users of the pacman package can now use all annotater functions on p_load calls. This includes calls with multiple package names (e.g. p_load(ggplot2,purrr)), which will be split up across lines for readability.

Installation

Install the CRAN release or the development version with:

# Install annotater from CRAN:
install.packages("annotater")
# install.packages("remotes")
remotes::install_github("luisDVA/annotater")

Restart RStudio after the installation for the addins to load properly.

When using the addins, make sure the focus (blinking cursor) is on an open RStudio R file in the ‘source’ pane.

Example

These are the possible annotations, which can be added to character strings (with one line per element), or applied to .R or .Rmd files in RStudio through their corresponding addins.

library(annotater)
test_string <-c("library(boot)\nrequire(Matrix)")
writeLines(annotate_pkg_calls(test_string))
writeLines(annotate_repo_source(test_string))
writeLines(annotate_repo_source(test_string))

Entire .R files can also be parsed and annotated with the annotate_script function.

A note on the tidyverse

The tidyverse package is a meta-package with few exported functions of its own, so the annotation tools provided here (annotate_fun_calls) will not match the functions from the various individual packages (such as dplyr or readr) that get attached when loading tidyverse. Consider using the experimental expand_metapackages function first if annotations for function calls are desired.

More on metapackages

annotater can now expand metapackage load calls into separate library calls for the individual packages that form the core of tidyverse, tidymodels, and easystats.

Feedback welcome

Thanks to Jonathan Carroll, Firat Melih Yilmaz, Paul Schmidt, and Achaz von Hardenberg for feedback and suggestions.

Metadata

Version

0.2.3

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows