Split your data into a list of data frames, e.g.,
dplyr::split(data, common_name) and then use purrr::map() on the
resulting list with .f = run_sdmtmb.
run(data, family, formula, dir_main = getwd(), n_knots = 500, ...)A list of sdmTMB lists, where each element in the list is the returned
object from sdmTMB::sdmTMB() when fitting data to a model and of the class
sdmTMB. The list of lists is because purrr::map2() is used to split the
input data by species and survey/source in case your data contain
combinations of these two categories in a long data frame.