Skip to contents

Apply a table of score specification, where each specification is represented as a row, to a data frame. The set of created scores are then added back to the original data frame as columns.

Usage

apply_scores(df, scores)

Arguments

df

A data frame to score.

scores

A data frame of score specifications. See scores_init.

Value

df, with scores added as columns.

See also

Examples

data <- tibble::tibble(
  x = 1:10
)

scores <- create_score(
  scores_init,
  score_type = "Linear", colname = "x", score_name = "Default",
  weight = 1, lb = 1, ub = 6, exponential = FALSE
)

apply_scores(data, scores)
#> # A tibble: 10 × 2
#>        x `Score 1: x`
#>    <int>        <dbl>
#>  1     1          0  
#>  2     2          0.2
#>  3     3          0.4
#>  4     4          0.6
#>  5     5          0.8
#>  6     6          1  
#>  7     7          1  
#>  8     8          1  
#>  9     9          1  
#> 10    10          1