Resolves a blank_rows specification (the same one as_rtftables()
accepts) into integer positions and stores them on
attr(data, "rtf_blank_rows"). Use this when you already have a
page-sized data.frame and only need to add blank rows – no
pagination required.
Usage
set_blank_rows(
data,
blank_rows = NULL,
blank_row_first = FALSE,
blank_row_end = FALSE,
group_col = NULL,
group_by = c("auto", "indent", "value", "filled"),
df
)Arguments
- data
A data.frame (or tibble).
- blank_rows
Blank-row specification. One of – or a
list()combining any of (positions are unioned):NULL(default) no positions from this argument.
- an integer vector
explicit positions:
0= before the first row,k= after rowk."between_groups"insert a blank at every group transition, using
group_by(the same detection as the pagination splits).- a
blank_rows_by_change()orblank_rows_by_rule()spec resolved per page (each carries its own rule /
group_by).
- blank_row_first
Logical, default
FALSE. WhenTRUE, also adds position0(blank row at the top ofdata).- blank_row_end
Logical, default
FALSE. WhenTRUE, also adds positionnrow(data)(blank row at the bottom ofdata).- group_col
Column name or 1-based index identifying the group, used only when
blank_rows = "between_groups".NULL(default) means detection on column 1 – seeas_rtftables().- group_by
How groups are recognised when
blank_rows = "between_groups":"auto"(default),"indent","value", or"filled"– the same detection as the pagination splits (seeas_rtftables()).- df
The old name of
data: deprecated in 0.8.x (warns once a session, still works), removed in 0.9.0.
Value
data with attr(., "rtf_blank_rows") updated. The
attribute is left absent when the resolved position set is
empty.
Details
as_rtftables() calls this function on every page it produces, so
the behaviour here defines what its blank_rows, blank_row_first
and blank_row_end arguments do.
See also
as_rtftables() for the per-page version; rtftable()
(read_attributes = TRUE) which consumes the attribute.
Examples
df <- data.frame(
label = c("Demographics", " Age", " Sex",
"Vitals", " HR", " BP"),
v = 1:6,
stringsAsFactors = FALSE
)
out <- set_blank_rows(df,
blank_rows = "between_groups",
blank_row_first = TRUE,
blank_row_end = TRUE)
attr(out, "rtf_blank_rows")
#> [1] 0 3 6