I have a tbl_df (tibble) named 'control.scores' that has a column called "Overall", which is some value between 1.00 and 4.00.
# A tibble: 2 x 8
group GOV CORC TMSC AUDIT PPS TRAIN Overall
<chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 Group4 0.82 0.2 0.525 0.2833333 0.2 0.2333333 2.261667
2 Group5 0.82 0.0 0.525 0.2833333 0.2 0.2333333 2.061667
I also have a another tbl_df, called 'control.rating.tbl' constructed:
# create a reference table of control ratings and numeric ranges
control.ref.tbl <- tribble(
~RATING, ~MIN, ~MAX,
"Ineffective", 3.500, 4.00,
"Marginally Effective",2.500 ,3.499,
"Generally Effective", 1.500 ,2.499,
"Highly Effective", 1.00, 1.499
)
How can I append one more column to 'control.scores' that uses the value in Overall and checks its position between the MIN and MAX range of 'control.rating.tbl' and return the string that corresponds?
E.g., Group4_Overall == '2.261667, which corresponds to 'Generally Effective' in 'control.rating.tbl'. It would look like this:
# A tibble: 2 x 8
group GOV CORC TMSC AUDIT PPS TRAIN Overall Rating
<chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 Group4 0.82 0.2 0.525 0.2833333 0.2 0.2333333 2.261667 Generally Effective
2 Group5 0.82 0.0 0.525 0.2833333 0.2 0.2333333 2.061667 Generally Effective