Skip to content
Snippets Groups Projects
Verified Commit 66a8612e authored by jens.preussner's avatar jens.preussner :ghost:
Browse files

Implemented exclude parameter

parent 6130d8eb
No related branches found
No related tags found
No related merge requests found
Pipeline #109524 passed
#' Method to assemble a dashboard to a Rmd file.
#'
#' @param dashboard A \linkS4class{i2dash::i2dashboard}.
#' @param pages A string or vector with the names of pages, which should be assemble to a report.
#' @param pages A string or vector with the names of pages, which should be assembled to a report.
#' @param file The output filename (recommend that the suffix should be '.Rmd'). This file will be saved in the working directory.
#' @param exclude A string or vector with the names of pages, which should be excluded from report assembly.
#' @param render A logical indicating whether the assembled report should immediately be rendered with \code{rmarkdown::render}.
#' @param ... Additional arguments passed on to \code{rmarkdown::render}.
#'
#' @rdname i2dashboard-methods
#' @export
setMethod("assemble", "i2dashboard", function(dashboard, pages = names(dashboard@pages), file = dashboard@file, render = FALSE, ...) {
setMethod("assemble", "i2dashboard", function(dashboard, pages = names(dashboard@pages), file = dashboard@file, exclude = NULL, render = FALSE, ...) {
tmp_document <- tempfile()
# Add YAML header
......@@ -24,6 +25,11 @@ setMethod("assemble", "i2dashboard", function(dashboard, pages = names(dashboard
knitr::knit_expand(file = system.file("templates", "i2dash-global-setup.Rmd", package = "i2dash"), delim = c("<%", "%>"), datadir = dashboard@datadir) %>%
cat(file = tmp_document, append = TRUE, sep = "\n")
# Handle exclusion of pages
if(!is.null(exclude)) {
pages <- pages[-na.omit(match(exclude, pages))]
}
# write page to tempfile
for (pagename in pages){
name <- .create_page_name(pagename)
......
......@@ -10,7 +10,7 @@
\usage{
\S4method{assemble}{i2dashboard}(dashboard,
pages = names(dashboard@pages), file = dashboard@file,
render = FALSE, ...)
exclude = NULL, render = FALSE, ...)
\S4method{add_component}{i2dashboard,character}(dashboard, component,
page = "default", ...)
......@@ -23,10 +23,12 @@
\arguments{
\item{dashboard}{A \linkS4class{i2dash::i2dashboard}.}
\item{pages}{A string or vector with the names of pages, which should be assemble to a report.}
\item{pages}{A string or vector with the names of pages, which should be assembled to a report.}
\item{file}{The output filename (recommend that the suffix should be '.Rmd'). This file will be saved in the working directory.}
\item{exclude}{A string or vector with the names of pages, which should be excluded from report assembly.}
\item{render}{A logical indicating whether the assembled report should immediately be rendered with \code{rmarkdown::render}.}
\item{...}{Additional arguments passed on to \code{rmarkdown::render}.}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment