generated from carpentries/workbench-template-rmd
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I finally was able to run through the new grouped example, since #51 was merged!
I think we still have the problem where we're not using the absolute simplest type of branching. The list iteration list was a bit tricky because of the [[1]]
needed, but tar_group_by()
is also complex because it uses tarchetypes
, it is a target factory, and it hides the dplyr::group_by
that people know.
How about just pulling out a vector of species names, and branching over that?
list(
tar_target(penguins_csv_file, path_to_file("penguins_raw.csv"), packages="palmerpenguins"),
tar_target(penguins_data_raw, read_csv(penguins_csv_file, show_col_types=FALSE)),
tar_target(penguins_data, clean_penguin_data(penguins_data_raw)),
tar_target(
species_name,
penguins_data |> dplyr::pull(species) |> unique(),
),
tar_target(
species_summary,
penguins_data |> dplyr::filter(species == species_name) |> model_glance(),
pattern = map(species_name)
)
)
> tar_read(species_name)
[1] "Adelie Penguin (Pygoscelis adeliae)" "Gentoo penguin (Pygoscelis papua)"
[3] "Chinstrap penguin (Pygoscelis antarctica)"
> tar_read(species_summary)
# A tibble: 3 × 13
r.squared adj.r.squared sigma statistic p.value df logLik AIC BIC deviance df.residual
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
1 0.153 0.148 1.12 27.0 6.67e- 7 1 -231. 468. 477. 188. 149
2 0.414 0.409 0.754 85.5 1.02e-15 1 -139. 284. 292. 68.8 121
3 0.427 0.418 0.866 49.2 1.53e- 9 1 -85.7 177. 184. 49.5 66
# ℹ 2 more variables: nobs <int>, species_name <chr>
Metadata
Metadata
Assignees
Labels
No labels