MyNixOS website logo
Description

A Toolbox for Working with R Arrays in a Functional Programming Style.

A toolbox for R arrays. Flexibly split, bind, reshape, modify, subset and name arrays.

listarrays

CRANstatus CRAN RStudio mirrordownloads

A toolbox for working with R arrays in a functional programming style. Flexibly split, bind, reshape, modify, subset, and name arrays.

The package provides:

  • split_on_dim() and split_along_dim() which take an array and return a list.

  • bind_on_dim() and bind_as_dim() take a list and return an array.

  • modify_along_dim() takes an array, calls the passed function .f() on each subset of the specified dimension, and returns an array of the same shape. (think of this as a safer and sometimes faster alternative to base::apply() that is guaranteed to return an array of the same shape as it received)

  • extract_dim() a wrapper around [ that allows you to specify the dimension being subset as a function argument. For example, extract_dim(X, 1, idx) will extract idx on the first dimension, regardless how many dimensions are in the array X. Contrast this with the base alternative X[idx,,], where you have to match the number of commas , to the number of dimensions in X.

  • Many of the functions have two variants *_rows() and *_cols() for the two most common case of the first and last dimension. For example split_on_rows() which is equivalent to split_on_dim(X, 1) and split_on_cols() which is equivalent to split_on_dim(X, -1)

  • set_dim() and set_dimnames(), pipe-friendly and more flexible versions of dim<- and dimnames<-

  • dim2()<-, set_dim2(), array2(), which reshape or fills arrays using row-major (C-style) semantics

  • A handful of lower-level helpers that abstract out patterns commonly encountered while working with arrays, for example expand_dims() (the inverse of base::drop(), or seq_along_rows() (a combination of seq_along() and nrow()).

  • A set of functions that help encode atomic vectors as onehot() binary matrix’s and decode_onehot() back into atomic vectors. (for example if training a neural network with keras)

  • Many of the functions work recursively if provided a list of arrays.

Installation

You can install listarrays from CRAN with:

install.packages("listarrays")

Or install the development version from github with:

devtools::install_github("t-kalinowski/listarrays")
Metadata

Version

0.4.0

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