what_needs_repair_within_block: A helper function that updates the 'repair_status' of...

Description Usage Arguments Details Value Examples

View source: R/repair.R

Description

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.

Usage

1
what_needs_repair_within_block(block_tibble, per_block_spend)

Arguments

block_tibble

a block dataframe or tibble with a costsvariable.

per_block_spend

a scalar calculated from repair_monies / number of blocks.

Details

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.

Value

A block_tibble that has had building components ready to be repaired or not indicated by the new variable repair_status.

Examples

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
               

DFE-Capital/blockbuster documentation built on May 26, 2019, 7:23 a.m.