library(ssddata)
library(ssdtools)
library(tidyverse)
<- ssdtools::ssd_fit_dists(ssddata::ccme_boron)
dist <- predict(dist, ci = FALSE)
pred
::ssd_plot_cdf(dist) +
ssdtoolsgeom_line(data = pred, aes(x = est, y = percent/100))
An elegant approach using some tidyverse packages is demonstrated below.
library(ssddata)
library(ssdtools)
library(tidyverse)
<- nest(ccme_boron, data = c(Chemical, Species, Conc, Units)) %>%
boron_preds 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.
ssd_plot(ccme_boron, boron_preds, xlab = "Concentration (mg/L)", ci = FALSE) +
facet_wrap(~Group)
ssdtools by the Province of British Columbia
is licensed under a
Creative Commons Attribution 4.0 International License.