Description Usage Arguments Details Value Examples
Outputs a block_tibble after spending per_block_spend
on one block. Used in the
repair
function. A new binary variable is created of the repair_status
of each building component within the block (later dropped in the repair
function).
The building components are sorted by
descending grade and then descending cost in the repair
function prior to
being passed to this helper function.
1 | what_needs_repair_within_block(block_tibble, per_block_spend)
|
block_tibble |
a block dataframe or tibble with a |
per_block_spend |
a scalar calculated from |
This function works by first checking if there's anything to repair in the block. If not,
it returns the input argument block_tibble
. Only building components of grade
B, C or D are considered for repair. If a building component has a repair cost of zero
it is also ignored for repair (these two logical tests are applied using an "OR"). As the
passed tibble would have been sorted by grade and then cost the function proceeds through
the sorted dataframe repairing what building components it can until all the money is spent.
Money is divided evenly between each buildingid
or block based on the repair
function.
A block_tibble
that has had building components ready to be
repaired or not indicated
by the new variable repair_status
.
1 2 3 4 5 | example <- what_needs_repair_within_block(
tibble::tibble(cost = seq(from = 0, to = 4500, by = 500),
grade = c("A", "B", "C", "D", "E", "B", "C", "N", "D", "B")),
1e4)$repair_status
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.