Description Usage Arguments Details Value Examples
An efficient recursive algorithm used by Rebuild that outputs
the keys corresponding to the unique combination of elements in the
ordered vector vec that sum to less than budget.
1  | RecursiveBudgeting(vec, keys, budget, state = NULL)
 | 
vec | 
 A numeric vector. When called by   | 
keys | 
 A vector. When called by   | 
budget | 
 A number.  | 
state | 
 (optional) This holds the selected keys during recursion.  | 
The vec and keys arguments are split into two.  The sum of the
first half of vec is compared to the budget.  If it is less then all
keys are selected, otherwise, the argument is split in half again and checked,
and so on.  Afterwards, the second half is checked if there are still monies
to spend.
A list.  .$state holds the selected keys while .$budget
holds the unused budget.
1 2 3 4 5  | # Ten buildings have rebuild costs between one to ten. Spend 12 to rebuild
# the first four
blockbuster2:::RecursiveBudgeting(1:10, 1:10, 12)
# If the costs are reversed, the decision changes as the vector is ordered
blockbuster2:::RecursiveBudgeting(10:1, 1:10, 12)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.