Skip to content
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: clinify
Type: Package
Title: Clinical Table Styling Tools and Utilities
Version: 0.3.0
Version: 0.3.0.9000
Authors@R: c(
person(given = "Mike",
family = "Stackhouse",
Expand All @@ -19,7 +19,7 @@ Depends:
R (>= 4.2)
Imports:
flextable,
officer (>= 0.6.9),
officer (>= 0.7.2),
magrittr,
dplyr,
knitr,
Expand Down
10 changes: 8 additions & 2 deletions R/pagination.R
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ clin_auto_page <- function(
#' @noRd
auto_page_ <- function(x) {
group_var <- x$clinify_config$auto_page_var
drop <- x$clinify_config$auto_page_drop
refdat <- x$body$dataset
refvar <- refdat[, group_var]

Expand All @@ -505,8 +506,13 @@ auto_page_ <- function(x) {
keep <- (1:length(refvar))[-dont_keep]

x <- flextable::keep_with_next(x, i = keep)
if (x$clinify_config$auto_page_drop) {
x <- flextable::delete_columns(x, j = group_var)
if (drop) {
x <- slice_clintable(
x,
1:nrow(refdat),
which(x$col_keys != group_var),
reapply_config = TRUE
)
}
x
}
6 changes: 4 additions & 2 deletions R/slice_clintable.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ slice_clintable <- function(
1:nrow(x$header$dataset),
columns
)

out$footer <- slice_complex_tabpart(
x$footer,
1:nrow(x$footer$dataset),
columns
)

out$body <- slice_complex_tabpart(x$body, rows, columns)

# Pull up the formatting of the very bottom row
Expand All @@ -61,7 +63,7 @@ slice_clintable <- function(

# If the column headers have spanners, then it's possible
# the horizontal span is too wide for the vector
if (!skip_spans) {
if (!skip_spans && nrow(x$header$dataset) > 0) {
for (i in seq_along(dim(out$header$spans$rows)[1])) {
out$header$spans$rows[i, ] <- adjust_span_row(
out$header$spans$rows[i, ],
Expand Down Expand Up @@ -148,7 +150,7 @@ slice_complex_tabpart <- function(x, rows, columns) {
rows <- numeric()
}

dataset <- x$dataset[rows, columns]
dataset <- x$dataset[rows, columns, drop = FALSE]

# Content element
content <- slice_chunkset_struct(x$content, rows, columns)
Expand Down
9 changes: 8 additions & 1 deletion R/styles.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ clinify_table_default <- function(x, ...) {

# Remove blank bottoms
blk_inds <- which(
x$header$dataset == "" | x$header$dataset == " ",
apply(x$header$dataset, c(1, 2), trimws) == "",
arr.ind = TRUE
)
# Want to ignore bottom row
Expand Down Expand Up @@ -176,6 +176,13 @@ clinify_grouplabel_default <- function(x, ...) {
part = "header",
border = officer::fp_border()
)
# Font and fontsize can get lost if the header is deleted, like
# with figures
# Set font properties for the table header.
x <- flextable::font(x, part = "all", fontname = "Courier New")

# Set fontsize for both table header and table body.
x <- flextable::fontsize(x, part = "all", size = 9)
}

#' @family Clinify Defaults
Expand Down
Loading