whoPays: Splits a vector in 2 shorter ones depending on the amount a...

View source: R/whoPays.R

whoPaysR Documentation

Splits a vector in 2 shorter ones depending on the amount a person should be reimbursed of.

Description

This is an internal function. It should not be called directly by the user.

Usage

whoPays(pos, neg)

Arguments

pos

Numeric vector containing the amount of money some people in the group have spend in excess and should be reimbursed of. Idealy, the vector should have a name for each value.

neg

Numeric vector containing the amount of money some people in the group should reimburse to balance the spendings. Idealy, the vector should have a name for each value.

Value

A list of 2 numerical vectors. Remb contains the values that a set of people need to spend to reimburse the first person in the pos vector. Reste contains the value that each debtor has still to spend to reimburse the remaining people in the pos vector.

Examples

pos <- c(125, 346)
names(pos) <- c("John", "Gail")
neg <- c(28, 312, 41, 90)
names(neg) <- c("Mike", "Lenny", "Christine", "Sally")
whoPays(pos,neg)

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