dispatch: Distributes debts among several persons

View source: R/dispatch.R

dispatchR Documentation

Distributes debts among several persons

Description

When several persons participate in an event and spendings ares not evenly distributed among participants, dispatch provides a clear view of who owes how much money to whom.

Usage

dispatch(balance, order = c("Who", "Whom"), round = 2)

Arguments

balance

Numeric vector of length greater or equal to 2. The sum should equal 0 since balance contains positive values for people having spend more money than they should have, and negative values for people having spend less money than they should have. Idealy, the vector should be named (see example below)

order

A character string specifying the sorting method to use for the output. Must be either "Who" (the default) or "Whom" (see examples).

round

Integer. With how many digits should amounts owed be displayed. Defaults to 2

Value

A 3-column data frame containing the name of the person owing the money, the amount owed and the recipient.

Examples

balance <- c(125, 346, -28, -312, -41, -90)
names(balance) <- c("John", "Gail", "Mike", "Lenny", "Christine", "Sally")
dispatch(balance)
dispatch(balance, order="Whom")

besibo/compteR documentation built on April 18, 2023, 6:36 a.m.