find_least_cost_partition: Find lowest-cost way to assemble units of different sizes to...

Description Usage Arguments Value Examples

View source: R/convenience.R

Description

Find lowest-cost way to assemble units of different sizes to a certain total

Usage

1
2
find_least_cost_partition(desired_dose, available_units, subset_col = NULL,
  subset_val = NULL)

Arguments

desired_dose

the dose(s) required.

available_units

available sizes and costs; must have column names 'size' and 'cost'

subset_col

optionally, a column to select on.

subset_val

if subset_col is provided, the value to select on in that column.

Value

a data frame, with columns desired_dose, used_dose, waste, cost, and cost.no.waste

Examples

1
2
3
4
5
units <- data.frame(size = c(1000, 250, 200, 100, 50),
    cost = c(40, 11.5, 8.5, 5.5, 4.4))
find_least_cost_partition(450, available_units = units)
temp <- find_least_cost_partition(sample(250:450, 10, replace = TRUE), 
   available_units = units)

MattWiener/heemodFits documentation built on May 19, 2019, 8:21 a.m.