knitr::opts_chunk$set(echo = FALSE)
param <- as.vector(sort(unique(palmerpenguins::penguins$species)))
param_len <- length(param)

Purpose

Test Notebook.

Using tabset get all the penguin names in "tabs". Each section should print with a plotly plot and DT table. Cannot have multiples of either in single code chunk. That is, if did this as a single chunk instead of multiple with Children it wouldn't work. :)

Thanks to:

Children {.tabset}

param_num <- 1

# Define new environment
child_env <- new.env()
child_env$species <- "Adelie"
child_env$p_num <- param_num
child_env$p_len <- param_len

# knit the document and save the character output to an object
res <- knitr::knit_child(
  "species-child.Rmd",
  envir = child_env,
  quiet = TRUE
)

# Cat the object to make it render in your main document
if(child_env$species %in% param) {
  cat(res, sep = '\n')
}## IF ~ End
param_num <- 2

# Define new environment
child_env <- new.env()
child_env$species <- "fred"
child_env$p_num <- param_num
child_env$p_len <- param_len

# knit the document and save the character output to an object
res <- knitr::knit_child(
  "species-child.Rmd",
  envir = child_env,
  quiet = TRUE
)

# Cat the object to make it render in your main document
if(child_env$species %in% param) {
  cat(res, sep = '\n')
}## IF ~ End
param_num <- 3

# Define new environment
child_env <- new.env()
child_env$species <- "Chinstrap"
child_env$p_num <- param_num
child_env$p_len <- param_len

# knit the document and save the character output to an object
res <- knitr::knit_child(
  "species-child.Rmd",
  envir = child_env,
  quiet = TRUE
)

# Cat the object to make it render in your main document
if(child_env$species %in% param) {
  cat(res, sep = '\n')
}## IF ~ End
param_num <- 4

# Define new environment
child_env <- new.env()
child_env$species <- "Gentoo"
child_env$p_num <- param_num
child_env$p_len <- param_len

# knit the document and save the character output to an object
res <- knitr::knit_child(
  "species-child.Rmd",
  envir = child_env,
  quiet = TRUE
)

# Cat the object to make it render in your main document
if(child_env$species %in% param) {
  cat(res, sep = '\n')
}## IF ~ End


leppott/ContDataSumViz documentation built on Jan. 30, 2024, 10 p.m.