Skip to content

Commit

Permalink
feat: new argument expand_single in as_flextable.tabulator()
Browse files Browse the repository at this point in the history
If FALSE (default), groups with only one row will not be expanded with a title row.
  • Loading branch information
davidgohel committed Nov 15, 2022
1 parent e0379cd commit f38ccb1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: flextable
Type: Package
Title: Functions for Tabular Reporting
Version: 0.8.3
Version: 0.8.4.001
Authors@R: c(
person("David", "Gohel", role = c("aut", "cre"),
email = "david.gohel@ardata.fr"),
Expand All @@ -28,7 +28,7 @@ Imports:
xml2, data.table (>= 1.13.0), uuid (>= 0.1-4),
gdtools (>= 0.1.6), rlang,
base64enc, grid
RoxygenNote: 7.2.1
RoxygenNote: 7.2.2
Roxygen: list(markdown = TRUE)
Suggests:
testthat (>= 2.1.0),
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# flextable 0.8.4

## new features

- new argument `expand_single` in `as_flextable.tabulator()`. If FALSE, groups with only one
row will not be expanded with a title row.

# flextable 0.8.3

## new features
Expand Down
7 changes: 6 additions & 1 deletion R/as_flextable_tabulator.R
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ tabulator <- function(x, rows, columns,
#' @param spread_first_col if TRUE, first row is spread as a new line separator
#' instead of being a column. This helps to reduce the width and allows for
#' clear divisions.
#' @param expand_single if FALSE (the default), groups with only one
#' row will not be expanded with a title row. If TRUE,
#' single row groups and multi-row groups are all
#' restructured.
#' @param sep_w blank column separators'width to be used. If 0,
#' blank column separators will not be used.
#' @param unit unit of argument `sep_w`, one of "in", "cm", "mm".
Expand Down Expand Up @@ -280,6 +284,7 @@ as_flextable.tabulator <- function(
small_border = fp_border_default(width = .75),
rows_alignment = "left", columns_alignment = "center",
label_rows = x$rows, spread_first_col = FALSE,
expand_single = FALSE,
sep_w = .05, unit = "in", ...) {

# get necessary element
Expand All @@ -289,7 +294,7 @@ as_flextable.tabulator <- function(
columns <- x$columns

if(spread_first_col){
dat <- as_grouped_data(dat, groups = rows[1])
dat <- as_grouped_data(dat, groups = rows[1], expand_single = expand_single)
}

visible_columns <- x$visible_columns
Expand Down
6 changes: 6 additions & 0 deletions man/as_flextable.tabulator.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f38ccb1

Please sign in to comment.