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

## ----echo=FALSE, results='asis'-----------------------------------------------
# cat(sprintf(
#   'Source code of the simulation database: <a href="https://github.com/MeikeSteinhilber/sprtt_plan_sample_size" target="_blank" rel="noopener"><img src="https://img.shields.io/badge/GitHub-MeikeSteinhilber/sprtt__plan__sample__size-blue?logo=github" alt="GitHub" style="vertical-align:middle;"></a></span></p>'
# ))

## ----first-report-------------------------------------------------------------
# plan_sample_size(
#   f_expected = 0.25,   # Expected effect size
#   k_groups = 3,        # Number of groups
#   beta = 0.05,         # beta error rate
#   decision_rate = 0.85 # desired percentage of decisions
# )

## ----error-example, eval=FALSE------------------------------------------------
# # This will produce an error:
# plan_sample_size(f_expected = 0.22, k_groups = 3)
# #> Error: `f_expected` = 0.22 is not available.
# #> Please choose one of 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, or 0.4

## ----example-effect-sizes-----------------------------------------------------
# # report 1
# plan_sample_size(f_expected = 0.15, k_groups = 3, beta = 0.05)
# 
# # report 2
# plan_sample_size(f_expected = 0.35, k_groups = 3, beta = 0.05)

## ----example-custom-location--------------------------------------------------
# plan_sample_size(
#   f_expected = 0.25,
#   k_groups = 4,
#   output_dir = "~/Documents/research/sample_size_planning",
#   output_file = "study1_anova.html",
#   open = TRUE
# )

## ----workflow-scenarios-------------------------------------------------------
# # Define scenarios to compare
# scenarios <- data.frame(
#   effect = c(0.15, 0.20, 0.25),
#   label = c("conservative", "expected", "optimistic")
# )
# 
# # Generate reports for each scenario
# for (i in 1:(nrow(scenarios))) {
#   plan_sample_size(
#     f_expected = scenarios$effect[i],
#     k_groups = 3,
#     beta = 0.10,
#     output_dir = "sample_size_reports",
#     output_file = sprintf("plan_sample_size_%s.html", scenarios$label[i]),
#     open = FALSE,  # Don't open each one
#     overwrite = TRUE
#   )
# }
# 
# message("Generated ", nrow(scenarios), " sample size reports")

## ----download-explicit--------------------------------------------------------
# # Download simulation data manually
# download_sample_size_data()

## ----download-force-----------------------------------------------------------
# download_sample_size_data(force = TRUE)

## ----cache-status-------------------------------------------------------------
# cache_info()

## ----cache-clear--------------------------------------------------------------
# cache_clear()

## ----load-data-advanced-------------------------------------------------------
# # Load the complete simulation dataset (downloads automatically if not yet cached)
# loaded <- load_sample_size_data()
# 
# # Access the simulation data frame
# df_all <- loaded$data
# 
# # Check which dataset version this report is based on
# loaded$description  # short description
# loaded$version      # e.g. "v0.1.0-data"
# loaded$created      # date the dataset was created
# loaded$n_rep        # number of simulation iterations per condition

