ipu_matrix: Balance a matrix given row and column targets

Description Usage Arguments Value Examples

View source: R/ipu.R

Description

This function simplifies the call to 'ipu()' for the simple case of a matrix and row/column targets.

Usage

1
ipu_matrix(mtx, row_targets, column_targets, ...)

Arguments

mtx

a matrix

row_targets

a vector of targets that the row sums must match

column_targets

a vector of targets that the column sums must match

...

additional arguments that are passed to 'ipu()'. See ipu for details.

Value

A matrix that matches row and column targets

Examples

1
2
3
4
mtx <- matrix(data = runif(9), nrow = 3, ncol = 3)
row_targets <- c(3, 4, 5)
column_targets <- c(5, 4, 3)
ipu_matrix(mtx, row_targets, column_targets)

Example output

         [,1]      [,2]      [,3]
[1,] 1.991705 0.5043897 0.5039152
[2,] 1.897498 1.2501380 0.8523666
[3,] 1.110797 2.2454723 1.6437183

ipfr documentation built on April 2, 2020, 1:12 a.m.