## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 4 ) # Prefer source designs when developing from the package tree / Dropbox checkout if (dir.exists("../inst/designs")) { options(DesignLibrary.root = normalizePath("..", winslash = "/")) } library(DesignLibrary) library(DeclareDesign) library(ggplot2) ## ----echo = FALSE, results = "asis"------------------------------------------- path <- system.file("designs", "two_arm_simple.R", package = "DesignLibrary") if (!nzchar(path) || !file.exists(path)) { root <- tryCatch( DesignLibrary:::find_package_root(), error = function(e) NULL ) if (!is.null(root)) { path <- file.path(root, "inst", "designs", "two_arm_simple.R") } } code <- if (file.exists(path)) { paste(readLines(path, warn = FALSE), collapse = "\n") } else { "# two_arm_simple.R not found in this build" } cat("```r\n", code, "\n```\n", sep = "") ## ----list-designs------------------------------------------------------------- list_designs() ## ----make-default------------------------------------------------------------- my_design <- make_design("two_arm_simple") my_design ## ----make-and-simulate-------------------------------------------------------- make_design("two_arm_simple", b = 0.3) |> simulate_design(sims = 2) ## ----make-and-simulate-grid--------------------------------------------------- make_design("two_arm_simple", b = c(0, .3, .6), N = c(20, 1000)) |> simulate_design(sims = 100) |> ggplot(aes(estimate, p.value, color = factor(b))) + geom_point() + facet_grid(N~.) ## ----shiny, eval = FALSE------------------------------------------------------ # designs_shiny_app() ## ----maintainer-root, eval = FALSE-------------------------------------------- # options(DesignLibrary.root = "C:/path/to/DesignLibrary") # refresh_library()