MyNixOS website logo
Description

R6 Dictionary Interface.

Efficient object-oriented R6 dictionary capable of holding objects of any class, including R6. Typed and untyped dictionaries are provided as well as the 'usual' dictionary methods that are available in other OOP languages, for example listing keys, items, values, and methods to get/set these.

dictionar6

CRAN StatusBadge CRANChecks R-CMD-check /codecov

RepoStatus Lifecycle

CRANDownloads codecov dependencies License:MIT

What is dictionar6?

dictionar6 is an R6 dictionary interface that makes use of symbolic representation to efficiently store R6 and non-R6 objects as symbols to prevent issues with cloning, large object sizes, or construction bottlenecks. The dictionary contains all ‘usual’ methods for getting and setting elements.

Main Features

Some main features/key use-cases of dictionar6 includes:

  • Construction of untyped dictionaries
dct(a = 1, b = "2")
## {a: 1, b: 2}
  • Construction of typed dictionaries
dct(a = 1L, b = 2L, c = 3L, types = "integer")
## {a: 1, b: 2, c: 3}
  • Getting values
d <- dct(a = 1, b = 2)
d$has("a")
## [1] TRUE
d$get("a")
## [1] 1
d[c("a", "b")]
## $a
## [1] 1
## 
## $b
## [1] 2
  • Setting values
d <- dct(a = 1, b = 2)
d$rekey("a", "c")
d$keys
## [1] "c" "b"
d$revalue("b", 3)
d$items
## $c
## [1] 1
## 
## $b
## [1] 3
  • Safe cloning of R6 objects
r <- RClass$new(1)
r$values()
## [1] 1
d <- dct(a = r)
# default is to clone
d$get("a", clone = TRUE)$add(2)
# r is unaffected
r$values()
## [1] 1
# if we don't clone...
d$get("a", clone = FALSE)$add(2)
# r is affected
r$values()
## [1] 1 2

Installation

For the latest release on CRAN, install with

install.packages("dictionar6")

Otherwise for the latest stable build

remotes::install_github("xoopR/dictionar6")

Use-cases

dictionar6 is currently used in param6 to provide a symbolic representation for R6 classes. This is incredibly useful to prevent storing unnecessarily large R6 objects. param6 comes pre-loaded with a Dictionary of mathematical sets where the keys are symbolic representations of the sets and the values are the sets themselves, this allows users to refer to R6 objects with their character representation without having to continually construct new objects.

Future Plans

The dictionar6 API is still experimental and may be subject to major changes. Currently it’s primary use-case is in param6, minor or major changes will be made to satisfy this dependency. Future development will then focus on code quality and speed.

Package Development and Contributing

dictionar6 is released under the MIT licence. We welcome and appreciate all new issues relating to bug reports, questions and suggestions. You can also start a discussion for more extensive feedback or feature suggestion.

Metadata

Version

0.1.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