
Create new columns to an officer summary data.frame based on specific levels
Source:R/summary_levels.R
officer_summary_levels.Rdofficer_summary_levels() works with fill_with_pattern() to help convert
hierarchically organized text, e.g. text with leveled headings or other
styles into a data.frame where new columns hold the value of the preceding
(or succeeding) heading text.
Usage
officer_summary_levels(
x,
levels = NULL,
levels_from = "style_name",
exclude_levels = NULL,
fill_col = "text",
direction = c("down", "up", "downup", "updown"),
...,
strict = FALSE,
call = caller_env()
)Arguments
- x
A input data.frame (assumed to be from
officer_summary()for default values).- levels
Levels to use. If
NULL(default), levels is set to unique, non-NA values from the levels_from column.- levels_from
Column name to use for identifying levels. Defaults to "style_name".
- exclude_levels
Levels to exclude from process of adding new columns.
- fill_col
Name of column to fill , Defaults to "text".
- direction
Direction of fill passed to
vctrs::vec_fill_missing(), Default: c("down", "up", "downup", "updown")- ...
Arguments passed on to
officer_summaryas_tibbleIf
TRUE(default), return a tibble data frame.summary_typeSummary type. Options "doc", "docx", "pptx", "slide", or "layout". "doc" requires the data.frame include a "content_type" column but allows columns for either a docx or pptx summary.
indexslide index
preserveIf
FALSE(default), text in table cells is collapsed into a single line. IfTRUE, line breaks in table cells are preserved as a "\n" character. This feature is adapted fromdocxtractr::docx_extract_tbl()published under a MIT licensed in the{docxtractr}package by Bob Rudis.
- strict
If
TRUE, error unless all values provided tolevelare present in thelevels_fromcolumn. Defaults toFALSEwhich warns if invalid values are present.- call
The execution environment of a currently running function, e.g.
caller_env(). The function will be mentioned in error messages as the source of the error. See thecallargument ofabort()for more information.
See also
Other summary functions:
check_officer_summary(),
officer_summary()