set.seed(15) # make this example reproducible
x <- rnorm(100, mean = 100, sd = 5)
cv(x)
## [1] 0.04944505
# the cv function can also be used within a call to dplyr::summarise
library(dplyr)
carbon.fabric %>%
filter(test == "WT") %>%
group_by(condition) %>%
summarise(mean = mean(strength), cv = cv(strength))
## # A tibble: 3 x 3
## condition mean cv
##
## 1 CTD 137. 0.0417
## 2 ETW 135. 0.0310
## 3 RTD 142. 0.0451
Run the code above in your browser using DataLab