library(dplyr)
# Calculate the average concentration of each substance and number of occurrences.
climber_drugs %>%
group_by(substance) %>%
summarize(count = n(), mean_con = mean(concentration))
# Proportion samples in which each substance was detected.
climber_drugs %>%
group_by(substance) %>%
summarize(prop = n() / 154)
Run the code above in your browser using DataLab