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.
Arguments
- df
A data frame to score.
- scores
A data frame of score specifications. See scores_init.
See also
scores_init for the format of the
scores
table.create_score()
anddelete_scores()
to create, edit and delete score specifications.score_final()
to create a final score after these scores have been created.
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