Skip to contents

Create risk vector based on ratio, number of places, or data frame

Usage

rv_create_risk_vector(
  risk_ratio,
  total_places,
  risk_places = NULL,
  risk_names = NULL
)

Arguments

risk_ratio

A numeric vector or a data frame with two columns, `Risk` and `Ratio`

total_places

Numeric. Gives the total length of the output vector.

risk_places

A numeric vector or a data frame with two columns, `Risk` and `Places`

risk_name

If a numeric vector given in previous parameters, defines the name of the risk.

Value

A character vector with length equal to total_places.

Examples



rv_create_risk_vector(
  risk_ratio = 0.1,
  total_places = 100
)
table(
  rv_create_risk_vector(
    risk_ratio = 0.1,
    total_places = 100
  )
)
#> 
#>  1 
#> 10 

ratio <- tibble::tribble(
  ~Risk, ~Ratio,
  "Hospitalization", 0.3,
  "Death", 0.1
)

rv_create_risk_vector(
  risk_ratio = ratio,
  total_places = 100
)

table(
  rv_create_risk_vector(
    risk_ratio = ratio,
    total_places = 100
  )
)
#> 
#> Hospitalization           Death 
#>              30              10