Type: Package
Title: Templated Reporting Workflows in Word and PowerPoint
Version: 1.0.7
Maintainer: John Harrold <john.m.harrold@gmail.com>
Description: Automated reporting in Word and PowerPoint can require customization for each organizational template. This package works around this by adding standard reporting functions and an abstraction layer to facilitate automated reporting workflows that can be replicated across different organizational templates.
URL: https://onbrand.ubiquity.tools
BugReports: https://github.com/john-harrold/onbrand/issues
License: BSD_2_clause + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.2
VignetteBuilder: knitr
Imports: digest, dplyr, flextable, ggplot2, officer (≥ 0.3.7), stringr, rlang, yaml
Suggests: knitr, knitrdata, markdown, rmarkdown, testthat
NeedsCompilation: no
Packaged: 2025-07-22 03:16:17 UTC; jmh
Author: John Harrold ORCID iD [aut, cre], Bryan Smith [aut]
Depends: R (≥ 4.1.0)
Repository: CRAN
Date/Publication: 2025-07-22 14:50:02 UTC

onbrand: officer Abstraction Layer for Organizational Templates

Description

The onbrand package creates an abstraction layer that is easily configurable with a yaml file to allow for creation of reproducible reporting work flows across Word and PowerPoint templates.

Author(s)

Maintainer: John Harrold john.m.harrold@gmail.com (ORCID)

Authors:

See Also

https://github.com/john-harrold/onbrand


Populate Placeholder In Officer Report

Description

Places content in a PowerPoint placeholder for a given officer document.

Usage

add_pptx_ph_content(
  obnd,
  content_type,
  content,
  ph_label = NULL,
  user_location = NULL,
  verbose = TRUE
)

Arguments

obnd

onbrand report object

content_type

string indicating the content type

content

content (see details below)

ph_label

placeholder location (text, or NULL if user_location is used)

user_location

User specified location using ph_location() or NULL if ph_label is used.

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned onbrand object.

Details

For each content type listed below the following content is expected:

Value

officer pptx object with the content added

See Also

view_layout report_add_slide


Construct Table Span From Components

Description

Takes a large table, common rows, and header information and constructs a table that is a subset of those components using supplied ranges of rows and columns.

Usage

build_span(
  table_body = NULL,
  row_common = NULL,
  table_body_head = NULL,
  row_common_head = NULL,
  header_format = "text",
  obnd = NULL,
  row_sel = NULL,
  col_sel = NULL,
  table_alignment = "center",
  inner_border = officer::fp_border(color = "black", width = 0.3),
  outer_border = officer::fp_border(color = "black", width = 2),
  set_header_inner_border_v = TRUE,
  set_header_inner_border_h = TRUE,
  set_header_outer_border = TRUE,
  set_body_inner_border_v = TRUE,
  set_body_inner_border_h = FALSE,
  set_body_outer_border = TRUE,
  notes_detect = NULL
)

Arguments

table_body

Data frame with the body of the large table.

row_common

Data frame with the common rows.

table_body_head

Data frame or matrix with headers for the table body.

row_common_head

Data frame or matrix with headers for the common rows.

header_format

Format of the header either "text" (default) or "md" for markdown.

obnd

Optional onbrand object used to format markdown. The default NULL value will use default formatting.

row_sel

Indices of rows to build to the table with.

col_sel

Indices of columns to build to the table with.

table_alignment

Character string specifying the alignment #'of the table (body and headers). Can be "center" (default), "left", "right", or "justify"

inner_border

Border object for inner border lines defined using officer::fp_border()

outer_border

Border object for outer border lines defined using officer::fp_border()

set_header_inner_border_v

Boolean value to enable or disable inner vertical borders for headers

set_header_inner_border_h

Boolean value to enable or disable inner horizontal borders for headers

set_header_outer_border

Boolean value to enable or disable outer border for headers

set_body_inner_border_v

Boolean value to enable or disable inner vertical borders for the body

set_body_inner_border_h

Boolean value to enable or disable inner horizontal borders for the body

set_body_outer_border

Boolean value to enable or disable outer border borders for the body

notes_detect

Vector of strings to detect in output tables (example c("NC", "BLQ")).

Details

The way the data frames relate to each other are mapped out below. The dimensions of the different data frames are identified below (nrow x ncol)

                            col_sel
                      |<--------------->|

|--------------------------------------------| ---
|                 |   .                 .    |  ^
|                 |   .                 .    |  |
| row_common_head |   . table_body_head .    |  | m
|      m x n      |   .      m x c      .    |  |
|                 |   .                 .    |  v
|--------------------------------------------| ---
|                 |   .                 .    |  ^
|                 |   .                 .    |  |
|    row_common   |   .   table_body    .    |  |
|      r x n      |   .     r x c       .    |  |
|                 |   .                 .    |  |
|.................|..........................|  |     -
|                 |   ./  /  /  /  /  / .    |  |     ^
|                 |   .  /  /  /  /  /  .    |  | r   |
|                 |   . /  /  /  /  /  /.    |  |     | row_sel
|                 |   ./  /  /  /  /  / .    |  |     |
|                 |   .  /  /  /  /  /  .    |  |     v
|.................|...../../../../../../.... |  |     -
|                 |   .                 .    |  |
|                 |   .                 .    |  v
|--------------------------------------------| ---

|<--------------->|<------------------------>|
        n                    c

Value

list with the following elements

Examples

if(interactive()){

tbl_res = mk_lg_tbl()

res =
span_table(table_body      = tbl_res$lg_tbl_body,
           row_common      = tbl_res$lg_tbl_row_common,
           table_body_head = tbl_res$lg_tbl_body_head,
           row_common_head = tbl_res$lg_tbl_row_common_head,
           max_row         = 20,
           max_col         = 10,
           notes_detect    = c("BQL", "NC"))


# Notes detected in the first table:
res[["tables"]][["Table 1"]][["notes"]]

# First table as a data frame:
res[["tables"]][["Table 1"]][["df"]]

# First table as a flextable:
res[["tables"]][["Table 1"]][["ft"]]

}


Fetch Markdown Default Format from onbrand Object

Description

Used to extract the formatting elements for a given style from an onbrand object.

Usage

fetch_md_def(obnd, style = "default", verbose = TRUE)

Arguments

obnd

onbrand report object

style

name of style in md_def for the report type in obnd to fetch ("default")

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned onbrand object.

Value

list with the following elements

Examples

obnd = read_template(
   template = file.path(system.file(package="onbrand"), "templates", "report.docx"),
   mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))
obnd = fetch_md_def(obnd, style="default")
md_def =  obnd[["md_def"]]

Extracts Officer Object From Onbrand Report Object

Description

If you need modify the onbrand report object directly with officer functions you can use this function to extract the report object from the onbrand object.

Usage

fetch_officer_object(obnd, verbose = TRUE)

Arguments

obnd

onbrand report object

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned onbrand object.

Value

List with the following elements

See Also

set_officer_object

Examples


obnd = read_template(
      template = file.path(system.file(package="onbrand"), "templates", "report.pptx"),
      mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))

rpt = fetch_officer_object(obnd)$rpt


Fetch The Specified Report Formatting Information

Description

Returns a list of the default font format for the report element

Usage

fetch_report_format(obnd, format_name = "default", verbose = TRUE)

Arguments

obnd

onbrand report object

format_name

Name of report format to fetch; this is defined in the md_def

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned list. section for the given report type ("default")

Value

list containing the following elements

Examples

obnd = read_template(
       template = file.path(system.file(package="onbrand"), "templates", "report.pptx"),
        mapping = file.path(system.file(package="onbrand"), "templates", "report.yaml"))

fr = fetch_report_format(obnd)

Determines Type of Report Template

Description

Based on the file extension for a template

Usage

fetch_rpttype(template = NULL, verbose = TRUE)

Arguments

template

Name of PowerPoint or Word file

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned list.

Value

List with the following elements

Examples

rpttype = fetch_rpttype(template=
  file.path(system.file(package="onbrand"), "templates", "report.pptx"))


Fetch PowerPoint Placeholder

Description

Retrieves the placeholder name in PowerPoint for a specified layout element.

Usage

fph(obnd, template = NULL, pn = NULL, verbose = TRUE)

Arguments

obnd

onbrand report object

template

Name of slide template (name from templates in yaml mapping file)

pn

Placehodler name to fetch

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned list.

Value

List with the following elements

Examples

# Creating an onbrand object:
obnd = read_template(
      template = file.path(system.file(package="onbrand"), "templates", "report.pptx"),
      mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))

# Pulling out the placeholder information:
ph = fph(obnd, "two_content_header_text", "content_left_header")



Fetch Word Style

Description

Retrieves the style name in Word for a specified onbrand style name.

Usage

fst(obnd, osn = NULL, verbose = TRUE)

Arguments

obnd

onbrand report object

osn

onbrand Word style name to fetch

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned list.

Value

List with the following elements

Examples

# Creating an onbrand object:
obnd = read_template(
      template = file.path(system.file(package="onbrand"), "templates", "report.docx"),
      mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))

# Pulling out the placeholder information:
st = fst(obnd, "Heading_3")



Render Markdown in flextable Object

Description

Takes a flextable object and renders any markdown in the specified part.

Usage

ft_apply_md(ft, obnd = NULL, part = "body", prows = NULL, pcols = NULL)

Arguments

ft

Flextable object.

obnd

Optional onbrand object used to format markdown. The default NULL value will use default formatting.

part

Part of the table can be one of "all", "body" (default), "header", or "footer".

prows

Optional rows of the part to process, ignored when part = "all". Set to NULL (default) to process all rows.

pcols

Optional columns of the part to process, ignored when part = "all". Set to NULL (default) to process all columns.

Value

flextable with markdown applied

Examples

library(onbrand)
library(flextable)

df = data.frame(
 A = c("e^x^",      "text"),
 B = c("sin(x~y~)", "**<ff:symbol>S</ff>**~x~"))

ft = flextable(df) |>
     delete_part(part="header") |>
     add_header(values = 
       list(A= "*Italics*", 
            B= "**Bold**") )    |>
     theme_vanilla()            |>
     ft_apply_md(part="all")

ft

Parse Markdown for Officer

Description

Parses text in Markdown format and returns fpar and as_paragraph command strings to be used with officer

Usage

md_to_officer(
  str,
  default_format = list(color = "black", font.size = 12, bold = FALSE, italic = FALSE,
    underlined = FALSE, font.family = "Cambria (Body)", vertical.align = "baseline",
    shading.color = "transparent")
)

Arguments

str

string containing Markdown can contain the following elements:

  • paragraph: two or more new lines creates a paragraph

  • bold: can be either "**text in bold**" or "__text in bold__"

  • italics: can be either "*text in italics*" or "_text in italics_"

  • subscript: "Normal~subscript~"

  • superscript: "Normal^superscript^"

  • color: "<color:red>red text</color>"

  • shade: "<shade:#33ff33>shading</shade>"

  • font family: "<ff:symbol>symbol</ff>"

  • reference: "<ref:key>" Where "key" is the value assigned when adding a table or figure

default_format

list containing the default format for elements not defined with markdown default values.

   default_format = list(
      color          = "black",
      font.size      = 12,
      bold           = FALSE,
      italic         = FALSE,
      underlined     = FALSE,
      font.family    = "Cambria (Body)",
      vertical.align = "baseline",
      shading.color  = "transparent")

Value

list with parsed paragraph elements with the content added to the body, each paragraph can be found in a numbered list element (e.g. pgraph_1, pgraph_2, etc) each with the following elements:

Examples

res              = md_to_officer("Be **bold**!")
fpar_obj         = eval(parse(text=res$pgraph_1$fpar_cmd))
as_paragraph_obj = eval(parse(text=res$pgraph_1$as_paragraph_cmd))

Parse Markdown into Officer as_paragraph Result

Description

Used to take small markdown chunks and return the as_paragraph results. This function will take the markdown specified in str, calls md_to_officer, evals the as_paragraph field from the first paragraph returned, evals that result and returns the object from the as_paragraph command.

Usage

md_to_oo(strs, default_format = NULL)

Arguments

strs

vector of strings containing Markdown can contain the following elements:

default_format

list containing the default format for elements not defined with markdown default values (format the same as md_to_officer, default is NULL)

Value

list with the following elements

Examples

res = md_to_oo("Be **bold**")

Creates Large Table Data for Testing

Description

Generates a large table for testing multi-page table reports. It is used for testing span_table().

Usage

mk_lg_tbl()

Value

list with the following elements

Examples

res =  mk_lg_tbl()

Generate Report Previewing the Locations From Mapping File

Description

Takes an onbrand object with a loaded template and populates the template with the elements from the mapping file.

Usage

preview_template(obnd, verbose = TRUE)

Arguments

obnd

onbrand report object

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned onbrand object.

Value

onbrand object with template previews added and any messages passed along

Examples

obnd = read_template(
   template = file.path(system.file(package="onbrand"), "templates", "report.pptx"),
   mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))
obnd = preview_template(obnd)

obnd = read_template(
   template = file.path(system.file(package="onbrand"), "templates", "report.docx"),
   mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))
obnd = preview_template(obnd)

Read Word or PowerPoint Templates

Description

Takes a given template file/yaml mapping file combination, reads in that information, checks to make sure the mapping information is correct and then returns an onbrand object.

Usage

read_template(
  template = file.path(system.file(package = "onbrand"), "templates", "report.pptx"),
  mapping = file.path(system.file(package = "onbrand"), "templates", "report.yaml"),
  verbose = TRUE
)

Arguments

template

Name of PowerPoint or Word file to annotate (defaults to included PowerPoint template)

mapping

Name of yaml file with configuration information

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned onbrand object.

Value

onbrand object which is a list with the following elements:

Examples

obnd = read_template(
      template = file.path(system.file(package="onbrand"), "templates", "report.pptx"),
      mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))

obnd = read_template(
      template = file.path(system.file(package="onbrand"), "templates", "report.docx"),
      mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))


Add Content to Body of a Word Document Report

Description

Appends content to the body of a Word document

Usage

report_add_doc_content(
  obnd,
  type = NULL,
  content = NULL,
  fig_start_at = NULL,
  tab_start_at = NULL,
  verbose = TRUE
)

Arguments

obnd

onbrand report object

type

Type of content to add

content

Content to add

fig_start_at

Indicates that you want to restart figure numbering at the specified value (e.g. 1) after adding this content a value of NULL (default) will ignore this option.

tab_start_at

Indicates that you want to restart figure numbering at the specified value (e.g. 1) after adding this content a value of NULL (default) will ignore this option.

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned onbrand object.

Details

For each content types listed below the different content outlined is expected. Text can be specified in different formats: "text" indicates plain text, "fpar" is formatted text defined by the fpar command from the officer package, "ftext" is a list of formatted text defined by the ftext command, and "md" is text formatted in markdown format (?md_to_officer for markdown details).

Value

onbrand object with the content added to the body or isgood set to FALSE with any messages in the msgs field. The isgood value is a Boolean variable indicating the current state of the object.

Examples


# Read  Word template into an onbrand object
obnd = read_template(
 template = file.path(system.file(package="onbrand"), "templates", "report.docx"),
 mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))

# The examples below use the following packages
library(ggplot2)
library(flextable)
library(officer)

# Adding text
obnd = report_add_doc_content(obnd,
  type     = "text",
  content  = list(text="Text with no style specified will use the doc_def text format."))


# Text formatted with fpar
fpartext = fpar(
ftext("Formatted text can be created using the ", prop=NULL),
ftext("fpar ", prop=fp_text(color="green")),
ftext("command from the officer package.", prop=NULL))

obnd = report_add_doc_content(obnd,
 type     = "text",
 content  = list(text   = fpartext,
                 format = "fpar",
                 style  = "Normal"))

# Text formatted with markdown
mdtext = "Formatted text can be created using
**<color:green>markdown</color>** formatting"
obnd = report_add_doc_content(obnd,
 type     = "text",
 content  = list(text   = mdtext,
                 format = "md",
                 style  = "Normal"))


# Adding figures
p = ggplot() + annotate("text", x=0, y=0, label = "picture example")
imgfile = tempfile(pattern="image", fileext=".png")
ggsave(filename=imgfile, plot=p, height=5.15, width=9, units="in")

# From an image file:
obnd = report_add_doc_content(obnd,
type     = "imagefile",
content  = list(image   = imgfile,
               caption = "This is an example of an image from a file."))

# From a ggplot object
obnd = report_add_doc_content(obnd,
type     = "imagefile",
content  = list(image   = imgfile,
               caption = "This is an example of an image from a file."))


#Adding tables
tdf =    data.frame(Parameters = c("Length", "Width", "Height"),
                Values     = 1:3,
                Units      = c("m", "m", "m") )

# Word table
tab_cont = list(table   = tdf,
               caption = "Word Table.")
obnd = report_add_doc_content(obnd,
 type     = "table",
 content  = tab_cont)

# onbrand flextable abstraction:
tab_cont = list(table   = tdf,
               caption = "Word Table.")
obnd = report_add_doc_content(obnd,
type     = "table",
content  = tab_cont)

# flextable object
tab_fto = flextable(tdf)
obnd = report_add_doc_content(obnd,
 type     = "flextable_object",
 content  = list(ft=tab_fto,
                 caption  = "Flextable object created by the user."))

# Saving the report output
save_report(obnd, tempfile(fileext = ".docx"))


Add Slide and Content

Description

Creates a report slide and populates the content in placeholders and arbitrary locations.

Usage

report_add_slide(
  obnd,
  template = NULL,
  elements = NULL,
  user_location = NULL,
  verbose = TRUE
)

Arguments

obnd

onbrand report object

template

Name of slide template to use (name from templates in yaml mapping file)

elements

Content and type for each placeholder you wish to fill for this slide: This is a list with names set to placeholders for the specified template. Each placeholder is a list and should have a content element and a type element (see Details below).

user_location

List with arbitrary element names (see Details below)

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned onbrand object.

Details

To add content based on placeholder names consider the mapping information for the slide template title_slide with the two place holders title and subtitle.

rpptx:
 master: Office Theme
 templates:
   title_slide:
     title:
       type:         ctrTitle
       index:        1
       ph_label:     Title 1
       content_type: text
     subtitle:
       type:         subTitle
       index:        1
       ph_label:     Subtitle 2
       content_type: text

This shows how to populate a title slide with text:

obnd = report_add_slide(obnd,
 template = "title_slide",
 elements = list(
    title     = list( content      = "Slide Title",
                      type         = "text"),
    subtitle  = list( content      = "Subtitle",
                      type         = "text")))

To add content based on user defined locations you need to supply a list with the content, type, starting point and stopping point. You can use any template you wish, and you need to populate the user_location input. This consists of lists. The name of these lists can be arbitrary (text_example and fig_example below). Each list has a content and type, this is the same used in elements above. The start and stop each represent x and y coordinates. This is the fraction of the width and height of the slide measured from the upper left. So the start = c(0.5, 0) below means the box holding that content would start at the middle of the slide width and the top of the slide.

 #'obnd = report_add_slide(obnd,
 template = "two_content_header_text",
 user_location = list(
    text_example  = list( content      = "This is text",
                          type         = "text",
                          start        = c(.01,.02),
                          stop         = c(.3,.15)),
    fig_example   = list( content      = ggplot2::ggplot(),
                          type         = "ggplot",
                          start        = c(.5,0),
                          stop         = c(1,.5))
 )
)

See the function add_pptx_ph_content for a list of allowed values for type. Note that if mapping defines the content_type as text, you cannot use a list type. Similarly, if the content_type is defined as list, you cannot use a text type.

Value

onbrand report object with either the content added or isgood set to FALSE with any messages in the msgs field. The isgood value is a Boolean variable indicating the current state of the object.

See Also

add_pptx_ph_content view_layout

Examples

obnd = read_template(
      template = file.path(system.file(package="onbrand"), "templates", "report.pptx"),
      mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))

# Adding content based on placeholder elements
obnd = report_add_slide(obnd,
 template = "content_text",
 elements = list(
    title         = list( content      = "Text Example",
                          type         = "text"),
    sub_title     = list( content      = "Adding a slide with a block of text",
                          type         = "text"),
    content_body  = list( content      = "A block of text",
                          type         = "text")))

# Adding content based on specified locations
obnd = report_add_slide(obnd,
 template = "two_content_header_text",
 user_location = list(
    text_example  = list( content      = "This is text",
                          type         = "text",
                          start        = c(.01,.02),
                          stop         = c(.3,.15))))

Save Onbrand Report to a File

Description

Saves report in onbrand object to the specified file.

Usage

save_report(obnd, output_file = NULL, verbose = TRUE)

Arguments

obnd

onbrand report object

output_file

File name to save the report.

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned onbrand object.

Value

List with the following elements

Examples


obnd = read_template(
      template = file.path(system.file(package="onbrand"), "templates", "report.pptx"),
      mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))

save_report(obnd, tempfile(fileext = ".pptx"))

obnd = read_template(
      template = file.path(system.file(package="onbrand"), "templates", "report.docx"),
      mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))

save_report(obnd, tempfile(fileext = ".docx"))


Places Officer Object Into Onbrand Report Object

Description

After modifying a report object manually, you can return it to the onbrand object using this function.

Usage

set_officer_object(obnd, rpt = NULL, verbose = TRUE)

Arguments

obnd

onbrand report object

rpt

officer object

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned onbrand object.

Value

onbrand object with the report replaced

See Also

fetch_officer_object

Examples


obnd = read_template(
      template = file.path(system.file(package="onbrand"), "templates", "report.pptx"),
      mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))

# pulling out the report
rpt = fetch_officer_object(obnd)$rpt

# Modifications would be made here with officer directly

# Replacing the report into the onbrand object
obnd = set_officer_object(obnd, rpt)


Spread Large Table Over Smaller Tables

Description

Takes a large table and spreads it over smaller tables to paginate it. It will preserve common row information on the left and separate columns according to maximum specifications. The final tables will have widths less than or equal to both max_col and max_width, and heights less than or equal to both max_row and max_height.

Usage

span_table(
  table_body = NULL,
  row_common = NULL,
  table_body_head = NULL,
  row_common_head = NULL,
  header_format = "text",
  obnd = NULL,
  max_row = 20,
  max_col = 10,
  max_height = 7,
  max_width = 6.5,
  table_alignment = "center",
  inner_border = officer::fp_border(color = "black", width = 0.3),
  outer_border = officer::fp_border(color = "black", width = 2),
  set_header_inner_border_v = TRUE,
  set_header_inner_border_h = TRUE,
  set_header_outer_border = TRUE,
  set_body_inner_border_v = TRUE,
  set_body_inner_border_h = FALSE,
  set_body_outer_border = TRUE,
  notes_detect = NULL
)

Arguments

table_body

Data frame with the body of the large table.

row_common

Data frame with the common rows.

table_body_head

Data frame or matrix with headers for the table body.

row_common_head

Data frame or matrix with headers for the common rows.

header_format

Format of the header either "text" (default) or "md" for markdown.

obnd

Optional onbrand object used to format markdown. The default NULL value will use default formatting.

max_row

Maximum number of rows in output tables (A value of NULL will set max_row to the number of rows in the table).

max_col

Maximum number of columns in output tables (A value of NULL will set max_col to number of columns in the table).

max_height

Maximum height of the final table in inches (A value of NULL will use 100 inches).

max_width

Maximum width of the final table in inches (A value of NULL will use 100 inches).

table_alignment

Character string specifying the alignment #'of the table (body and headers). Can be "center" (default), "left", "right", or "justify"

inner_border

Border object for inner border lines defined using officer::fp_border()

outer_border

Border object for outer border lines defined using officer::fp_border()

set_header_inner_border_v

Boolean value to enable or disable inner vertical borders for headers

set_header_inner_border_h

Boolean value to enable or disable inner horizontal borders for headers

set_header_outer_border

Boolean value to enable or disable outer border for headers

set_body_inner_border_v

Boolean value to enable or disable inner vertical borders for the body

set_body_inner_border_h

Boolean value to enable or disable inner horizontal borders for the body

set_body_outer_border

Boolean value to enable or disable outer border borders for the body

notes_detect

Vector of strings to detect in output tables (example c("NC", "BLQ")).

Details

The way the data frames relate to each other are mapped out below. The dimensions of the different data frames are identified below (nrow x ncol)

 |-------------------------------------| ---
 |                 |                   |  ^
 |                 |                   |  |
 | row_common_head |  table_body_head  |  | m
 |      m x n      |       m x c       |  |
 |                 |                   |  v
 |-------------------------------------| ---
 |                 |                   |  ^
 |                 |                   |  |
 |    row_common   |    table_body     |  | r
 |      r x n      |      r x c        |  |
 |                 |                   |  |
 |                 |                   |  v
 |-------------------------------------| ---

 |<--------------->|<----------------->|
         n                   c

Value

list with the following elements

See Also

build_span for the relationship of inputs.

Examples

if(interactive()){

tbl_res = mk_lg_tbl()

res =
span_table(table_body      = tbl_res$lg_tbl_body,
           row_common      = tbl_res$lg_tbl_row_common,
           table_body_head = tbl_res$lg_tbl_body_head,
           row_common_head = tbl_res$lg_tbl_row_common_head,
           max_row         = 20,
           max_col         = 10,
           notes_detect    = c("BQL", "NC"))


# Notes detected in the first table:
res[["tables"]][["Table 1"]][["notes"]]

# First table as a data frame:
res[["tables"]][["Table 1"]][["df"]]

# First table as a flextable:
res[["tables"]][["Table 1"]][["ft"]]

}


Show Template Details for 'onbrand' Object

Description

Takes an onbrand object with a loaded template and displays relevant details about the template.

Usage

template_details(obnd, verbose = TRUE)

Arguments

obnd

onbrand report object

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal; Messages will be included in the returned results object.

Details

Provides relevant details about an onbrand object. For PowerPoint this contains the template names and elements present for that template. For Word it will contain defined text and table styles. This information can be displayed in the console, returned as text or formatted for use in RMarkdown documentation.

Value

list with the following elements:

Examples

obnd = read_template(
   template = file.path(system.file(package="onbrand"), "templates", "report.pptx"),
   mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))
details = template_details(obnd)

obnd = read_template(
   template = file.path(system.file(package="onbrand"), "templates", "report.docx"),
   mapping  = file.path(system.file(package="onbrand"), "templates", "report.yaml"))
details = template_details(obnd)

Generate Annotated Layout for Report Templates

Description

Produces a report with each layout element labeled.

Usage

view_layout(
  template = file.path(system.file(package = "onbrand"), "templates", "report.pptx"),
  output_file = NULL,
  verbose = TRUE
)

Arguments

template

Name of PowerPoint or Word file to annotate (defaults to included PoerPoint template)

output_file

name of file to place the annotated layout information, set to NULL and it will generate a file named layout with the appropriate extension

verbose

Boolean variable when set to TRUE (default) messages will be

Details

Generates an Annotated report based on the template provided. Elements of slide masters are identified by placeholder labels. As PowerPoint masters are created the labels can be difficult to predict. Word documents are identified by style names. This function will create a layout file identifying all of the elements of each slide master for a PowerPoint template or each paragraph and table style for a Word template.

Value

List with the following elements

Examples

lpptx = view_layout(
     template = file.path(system.file(package="onbrand"), "templates", "report.pptx"),
     output_file   = file.path(tempdir(), "layout.pptx"))

ldocx = view_layout(
     template = file.path(system.file(package="onbrand"), "templates", "report.docx"),
     output_file   = file.path(tempdir(), "layout.docx"))