Skip to content

Commit f38ccb1

Browse files
committed
feat: new argument expand_single in as_flextable.tabulator()
If FALSE (default), groups with only one row will not be expanded with a title row.
1 parent e0379cd commit f38ccb1

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎DESCRIPTION‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: flextable
22
Type: Package
33
Title: Functions for Tabular Reporting
4-
Version: 0.8.3
4+
Version: 0.8.4.001
55
Authors@R: c(
66
person("David", "Gohel", role = c("aut", "cre"),
77
email = "[email protected]"),
@@ -28,7 +28,7 @@ Imports:
2828
xml2, data.table (>= 1.13.0), uuid (>= 0.1-4),
2929
gdtools (>= 0.1.6), rlang,
3030
base64enc, grid
31-
RoxygenNote: 7.2.1
31+
RoxygenNote: 7.2.2
3232
Roxygen: list(markdown = TRUE)
3333
Suggests:
3434
testthat (>= 2.1.0),

‎NEWS.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# flextable 0.8.4
2+
3+
## new features
4+
5+
- new argument `expand_single` in `as_flextable.tabulator()`. If FALSE, groups with only one
6+
row will not be expanded with a title row.
7+
18
# flextable 0.8.3
29

310
## new features

‎R/as_flextable_tabulator.R‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ tabulator <- function(x, rows, columns,
233233
#' @param spread_first_col if TRUE, first row is spread as a new line separator
234234
#' instead of being a column. This helps to reduce the width and allows for
235235
#' clear divisions.
236+
#' @param expand_single if FALSE (the default), groups with only one
237+
#' row will not be expanded with a title row. If TRUE,
238+
#' single row groups and multi-row groups are all
239+
#' restructured.
236240
#' @param sep_w blank column separators'width to be used. If 0,
237241
#' blank column separators will not be used.
238242
#' @param unit unit of argument `sep_w`, one of "in", "cm", "mm".
@@ -280,6 +284,7 @@ as_flextable.tabulator <- function(
280284
small_border = fp_border_default(width = .75),
281285
rows_alignment = "left", columns_alignment = "center",
282286
label_rows = x$rows, spread_first_col = FALSE,
287+
expand_single = FALSE,
283288
sep_w = .05, unit = "in", ...) {
284289

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

291296
if(spread_first_col){
292-
dat <- as_grouped_data(dat, groups = rows[1])
297+
dat <- as_grouped_data(dat, groups = rows[1], expand_single = expand_single)
293298
}
294299

295300
visible_columns <- x$visible_columns

‎man/as_flextable.tabulator.Rd‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)