mouter(): a generalization of outer()

Build Status Build Status rstudio mirror downloads cran version

library(mouter)

knitr::opts_chunk$set(
  echo = TRUE,
  error = FALSE
  )

knitr::render_markdown(strict=FALSE)

Function mouter::mouter() generalizes (a bit) base::outer() so that it can be conviniently used to build joint frequency distributions from several marginal distributions.

Examples

We call mouter with a collection of vectors and/or arrays. They will correspond to margins. Say:

# As an array
a <- mouter(
  A = c(a=1, b=2) / 3,
  M = matrix(1:4 / 10, 2, 2, dimnames=list(D=letters[5:6], E=letters[7:8])),
  B = c(c=2, d=3) / 5,
  retval="a"
)

str(a)

Alternatively, mouter can return a data frame:

# Data frame
mouter(
  A = c(a=1, b=2) / 3,
  M = matrix(1:4 / 10, 2, 2, dimnames=list(D=letters[5:6], E=letters[7:8])),
  B = c(c=2, d=3) / 5,
  retval="df"
)

Installation

devtools::install_github("mbojan/mouter")


mbojan/mouter documentation built on May 22, 2019, 12:55 p.m.