Skip to contents

This function takes an input dataset and normalizes observations

Usage

normalize_observations(data, y_var, grouping_var, ref_values)

Arguments

data

input dataset to be plotted (required)

y_var

response variable, Y (required)

grouping_var

select grouping variable to normalize by (required)

ref_values

add reference (nominal) values. takes a string of values with values appearing in the same order as in grouping variable. string length must be equal to unique values in grouping variable (required)

Value

A tibble object with observations normalized and saved in a new column.

Examples

library(dplyr)

polar_small_multiples_data %>%
    filter(ID_Measurement_Angle %in% c(0, 45, 90, 135)) %>%
    normalize_observations(y_var = ID,
                           grouping_var = Tip_Bottom,
                           ref_values = c(0.2075, 0.2225))
#> Joining, by = "Tip_Bottom"
#> # A tibble: 64 × 7
#>    ID_Measurement_Angle Mold_Cavity_Number Tip_Bottom    ID  ID_2 ref_value
#>                   <dbl>              <dbl> <chr>      <dbl> <dbl>     <dbl>
#>  1                    0                  1 Bottom ID  0.207 0.103     0.208
#>  2                   45                  1 Bottom ID  0.207 0.103     0.208
#>  3                   90                  1 Bottom ID  0.207 0.103     0.208
#>  4                  135                  1 Bottom ID  0.208 0.104     0.208
#>  5                    0                  2 Bottom ID  0.207 0.103     0.208
#>  6                   45                  2 Bottom ID  0.207 0.103     0.208
#>  7                   90                  2 Bottom ID  0.207 0.104     0.208
#>  8                  135                  2 Bottom ID  0.207 0.104     0.208
#>  9                    0                  3 Bottom ID  0.207 0.103     0.208
#> 10                   45                  3 Bottom ID  0.208 0.104     0.208
#> # … with 54 more rows, and 1 more variable: ID_normalized <dbl>