blank columns are set as transparent. This is a shortcut function that will delete top and bottom borders, change background color to transparent, display empty content and set blank columns' width.

empty_blanks(x, width = 0.05, unit = "in", part = "all")

Arguments

x

a flextable object

width

width of blank columns (.1 inch by default).

unit

unit for width, one of "in", "cm", "mm".

part

partname of the table (one of 'all', 'body', 'header', 'footer')

See also

Other sugar functions for table style: align(), bg(), bold(), color(), fontsize(), font(), highlight(), italic(), line_spacing(), padding(), rotate(), valign()

Examples

typology <- data.frame(
  col_keys = c(
    "Sepal.Length", "Sepal.Width", "Petal.Length",
    "Petal.Width", "Species"
  ),
  what = c("Sepal", "Sepal", "Petal", "Petal", " "),
  measure = c("Length", "Width", "Length", "Width", "Species"),
  stringsAsFactors = FALSE
)
typology
#>       col_keys  what measure
#> 1 Sepal.Length Sepal  Length
#> 2  Sepal.Width Sepal   Width
#> 3 Petal.Length Petal  Length
#> 4  Petal.Width Petal   Width
#> 5      Species       Species

ftab <- flextable(head(iris), col_keys = c(
  "Species",
  "break1", "Sepal.Length", "Sepal.Width",
  "break2", "Petal.Length", "Petal.Width"
))
ftab <- set_header_df(ftab, mapping = typology, key = "col_keys")
ftab <- merge_h(ftab, part = "header")
ftab <- theme_vanilla(ftab)
ftab <- empty_blanks(ftab)
ftab <- width(ftab, j = c(2, 5), width = .1)
ftab
#> a flextable object.
#> col_keys: `Species`, `break1`, `Sepal.Length`, `Sepal.Width`, `break2`, `Petal.Length`, `Petal.Width` 
#> header has 2 row(s) 
#> body has 6 row(s) 
#> original dataset sample: 
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species break1 break2
#> 1          5.1         3.5          1.4         0.2  setosa              
#> 2          4.9         3.0          1.4         0.2  setosa              
#> 3          4.7         3.2          1.3         0.2  setosa              
#> 4          4.6         3.1          1.5         0.2  setosa              
#> 5          5.0         3.6          1.4         0.2  setosa