Skip to content

Commit

Permalink
Update plan 11
Browse files Browse the repository at this point in the history
  • Loading branch information
joelnitta committed Dec 23, 2024
1 parent cc6cb53 commit 5d11916
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions episodes/files/plans/plan_11.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,32 @@ tar_plan(
path_to_file("penguins_raw.csv"),
read_csv(!!.x, show_col_types = FALSE)
),
# Clean data
penguins_data = clean_penguin_data(penguins_data_raw),
# Build models
models = list(
combined_model = lm(
bill_depth_mm ~ bill_length_mm, data = penguins_data),
species_model = lm(
bill_depth_mm ~ bill_length_mm + species, data = penguins_data),
interaction_model = lm(
bill_depth_mm ~ bill_length_mm * species, data = penguins_data)
# Clean and group data
tar_group_by(
penguins_data,
clean_penguin_data(penguins_data_raw),
species
),
# Get model summaries
# Get summary of combined model with all species together
combined_summary = model_glance(penguins_data),
# Get summary of one model per species
tar_target(
model_summaries,
glance_with_mod_name(models),
pattern = map(models)
species_summary,
model_glance(penguins_data),
pattern = map(penguins_data)
),
# Get model predictions
# Get predictions of combined model with all species together
combined_predictions = model_glance(penguins_data),
# Get predictions of one model per species
tar_target(
model_predictions,
augment_with_mod_name(models),
pattern = map(models)
species_predictions,
model_augment(penguins_data),
pattern = map(penguins_data)
),
# Generate report
tar_quarto(
penguin_report,
path = "penguin_report.qmd",
quiet = FALSE,
packages = c("targets", "tidyverse")
quiet = FALSE
)
)

0 comments on commit 5d11916

Please sign in to comment.