## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## -----------------------------------------------------------------------------
# install.packages("toolero")

## -----------------------------------------------------------------------------
# pak::pak("erwinlares/toolero")

## -----------------------------------------------------------------------------
# library(toolero)
# 
# init_project(path = "~/Documents/my-project")

## -----------------------------------------------------------------------------
# init_project(
#   path          = "~/Documents/my-project",
#   extra_folders = c("notebooks", "presentations")
# )

## -----------------------------------------------------------------------------
# init_project(
#   path        = "~/Documents/my-project",
#   uw_branding = TRUE
# )

## -----------------------------------------------------------------------------
# create_qmd(path = "~/Documents/my-project", filename = "analysis.qmd")

## -----------------------------------------------------------------------------
# create_qmd(
#   path             = "~/Documents/my-project",
#   filename         = "analysis.qmd",
#   include_examples = FALSE
# )

## -----------------------------------------------------------------------------
# # Blank document with UW branding (assumes init_project(uw_branding = TRUE) was called)
# create_qmd(
#   path             = "~/Documents/my-project",
#   filename         = "report.qmd",
#   include_examples = FALSE,
#   use_style        = TRUE
# )
# 
# # Blank document with custom branding from a different directory
# create_qmd(
#   path             = "~/Documents/my-project",
#   filename         = "report.qmd",
#   include_examples = FALSE,
#   use_style        = "my-branding/"
# )

## -----------------------------------------------------------------------------
# create_qmd(
#   path     = "~/Documents/my-project",
#   filename = "notes.qmd",
#   use_purl = FALSE,
#   include_examples = FALSE
# )

## -----------------------------------------------------------------------------
# create_qmd(
#   path      = "~/Documents/my-project",
#   filename  = "analysis.qmd",
#   yaml_data = "~/my-metadata.yml"
# )

## -----------------------------------------------------------------------------
# data <- read_clean_csv("data/my-file.csv")

## -----------------------------------------------------------------------------
# # Treat dots, dashes, and -999 as missing in addition to blanks and "NA"
# data <- read_clean_csv("data/my-file.csv", na = c("", "NA", "N/A", ".", "-999"))

## -----------------------------------------------------------------------------
# # Keep all rows, including those with missing values (default)
# data <- read_clean_csv("data/my-file.csv", drop_na = FALSE)
# 
# # Drop any row that has a missing value in any column
# data <- read_clean_csv("data/my-file.csv", drop_na = TRUE)
# 
# # Drop rows only where specific columns are missing
# data <- read_clean_csv("data/my-file.csv", drop_na = c("bill_length_mm", "sex"))

## -----------------------------------------------------------------------------
# data <- read_clean_csv("data/my-file.csv", summary = TRUE)

## -----------------------------------------------------------------------------
# data <- read_clean_csv("data/my-file.csv", verbose = TRUE)

## -----------------------------------------------------------------------------
# data <- read_clean_csv(
#   "data/my-file.csv",
#   na      = c("", "NA", "N/A", "."),
#   drop_na = TRUE,
#   summary = TRUE
# )

## -----------------------------------------------------------------------------
# # Force a column to character instead of letting readr guess
# data <- read_clean_csv("data/my-file.csv", col_types = cols(zip_code = col_character()))
# 
# # Skip the first two rows (e.g. metadata rows before the header)
# data <- read_clean_csv("data/my-file.csv", skip = 2)
# 
# # Handle European-style decimals (comma as decimal separator)
# data <- read_clean_csv("data/my-file.csv", locale = locale(decimal_mark = ","))

## -----------------------------------------------------------------------------
# write_by_group(
#   data       = penguins,
#   group_col  = "species",
#   output_dir = "results/by-species"
# )

## -----------------------------------------------------------------------------
# write_by_group(
#   data       = penguins,
#   group_col  = "species",
#   output_dir = "results/by-species",
#   manifest   = TRUE
# )

## -----------------------------------------------------------------------------
# context <- detect_execution_context()
# 
# input_file <- switch(context,
#   interactive = "data/sample.csv",
#   quarto      = params$input_file,
#   rscript     = commandArgs(trailingOnly = TRUE)[1]
# )

## -----------------------------------------------------------------------------
# generate_kb_xml(
#   html_path  = "docs/analysis.html",
#   output_dir = "exports"
# )

## -----------------------------------------------------------------------------
# citation("toolero")

