# Transform data according to the modified CV transformation
# and report the original and modified CV for each condition
library(dplyr)
carbon.fabric %>%
filter(test == "FT") %>%
group_by(condition) %>%
mutate(trans_strength = transform_mod_cv(strength)) %>%
head(10)
## # A tibble: 10 x 6
## # Groups: condition [1]
## id test condition batch strength trans_strength
##
## 1 FT-RTD-1-1 FT RTD 1 126. 126.
## 2 FT-RTD-1-2 FT RTD 1 139. 141.
## 3 FT-RTD-1-3 FT RTD 1 116. 115.
## 4 FT-RTD-1-4 FT RTD 1 132. 133.
## 5 FT-RTD-1-5 FT RTD 1 129. 129.
## 6 FT-RTD-1-6 FT RTD 1 130. 130.
## 7 FT-RTD-2-1 FT RTD 2 131. 131.
## 8 FT-RTD-2-2 FT RTD 2 124. 124.
## 9 FT-RTD-2-3 FT RTD 2 125. 125.
## 10 FT-RTD-2-4 FT RTD 2 120. 119.
# The CV of this transformed data can be computed to verify
# that the resulting CV follows the rules for modified CV
carbon.fabric %>%
filter(test == "FT") %>%
group_by(condition) %>%
mutate(trans_strength = transform_mod_cv(strength)) %>%
summarize(cv = sd(strength) / mean(strength),
mod_cv = sd(trans_strength) / mean(trans_strength))
## # A tibble: 3 x 3
## condition cv mod_cv
##
## 1 CTD 0.0423 0.0612
## 2 ETW 0.0369 0.0600
## 3 RTD 0.0621 0.0711
Run the code above in your browser using DataLab