cross_tab_margins: Cross tabulate two vectors with given margins

View source: R/RcppExports.R

cross_tab_marginsR Documentation

Cross tabulate two vectors with given margins

Description

this is a replacement for table that allows empty cells because the margins have been specified. The input vectors a and b must be the same length, this function does no argument checking.

Usage

cross_tab_margins(a, b, a_margin, b_margin)

Arguments

a

one set of observations

b

another set of observations

a_margin

number of distinct values of a (rows)

b_margin

number of distinct values of b (cols)

Examples

a <- 1:5
b <- c(1,2,3,1,2)
cross_tab_margins(a,b,5,3)
table(a,b)

mrc-ide/safir documentation built on Aug. 2, 2022, 10:47 a.m.