MyNixOS website logo
Description

Extending Base 'R' Lists.

Extends the functionality of base 'R' lists and provides specialized data structures 'deque', 'set', 'dict', and 'dict.table', the latter to extend the 'data.table' package.

CRAN_Status_Badge dependencies codecov.io R-CMD-check downloads total-downloads last-commit Lifecycle_Badge

container

container provides an enhanced version of base R’s list with a carefully designed set of extract, replace, and remove operations that make it easier and safer to work with list-like data structures.

Why container?

  • safe and flexible operations to
    • extract (built-in default values, no unintended NULL)
    • add and replace (mixed indices, no unintended overrides)
    • remove (loose or strict deletion, remove by index or value)
  • compact printing
  • optional reference semantics

In addition, this package provides specialized data structures Deque, Set and Dict and a special class dict.table, designed to extend data.table by container operations to safely Manage data columns with dict.table.

Installation

# Install release version from CRAN
install.packages("container")

# Install development version from GitHub
devtools::install_github("rpahl/container")

Usage

library(container)
co <- container(colors = c("Red", "Green"), numbers = c(1, 2, 3), data = cars)
co
# [colors = ("Red" "Green"), numbers = (1 2 3), data = <<data.frame(50x2)>>]

Safe extract

at(co, "colours")   # oops
# Error: index 'colours' not found

at(co, "colors")
# [colors = ("Red" "Green")]

Safe remove

co <- delete_at(co, "colours")   # oops
# Error: names(s) not found: 'colours'

co <- delete_at(co, "colors")
co
# [numbers = (1 2 3), data = <<data.frame(50x2)>>]

Flexible peek

at(co, "colors")   # oops
# Error: index 'colors' not found

peek_at(co, "colors")
# []

peek_at(co, "colors", .default = c("black", "white"))
# [colors = ("black" "white")]

Safe replace

co <- replace_at(co, num = 1:10)   # oops
# Error: names(s) not found: 'num'

co <- replace_at(co, numbers = 1:10)
co
# [numbers = (1L 2L 3L 4L ...), data = <<data.frame(50x2)>>]

Getting Started

Metadata

Version

1.0.4

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