## Report section
# This is report is meant to be used as a section, or child document, of a struct_report.
# The report_section object is expected to be in the environment as "S".

# use default if no markdown provided
if (is.null(S$markdown)) {
    S$markdown=system.file(package='structReport','templates/default_object.Rmd',mustWork = TRUE)
}
p2md=system.file(package='structReport','templates/report_section.Rmd',mustWork = TRUE)
    txt=knitr::knit_child(input=S$markdown,quiet=TRUE)
    cat(paste(txt, collapse = '\n\n'))
# loop over child docs
G=S
txt=NULL
for (k in seq_len(length(G))) {
    # create env
    E=new.env(parent = as.environment(2))
    # set the section object for current child
    E$S = G$subsection[[k]]
    # set header level
    E$HDR_LVL = HDR_LVL+1
    # set parent model
    E$parent_object=S$object
    # add child
    txt=c(txt,knitr::knit_child(input=p2md,quiet=TRUE,envir=E))
}
cat(paste(txt, collapse = '\n'))


computational-metabolomics/structReport documentation built on Nov. 12, 2020, 2:33 a.m.