An elegant approach using some tidyverse packages is demonstrated below.
library(ssddata)
library(ssdtools)
library(ggplot2)
library(dplyr)
library(tidyr)
library(purrr)
boron_preds <- nest(ccme_boron, data = c(Chemical, Species, Conc, Units)) %>%
mutate(
Fit = map(data, ssd_fit_dists, dists = "lnorm"),
Prediction = map(Fit, predict)
) %>%
unnest(Prediction)
The resultant data and predictions can then be plotted as follows.
ssdtools by the Province of British Columbia
is licensed under a
Creative Commons Attribution 4.0 International License.