Learn R Programming

flextable (version 0.7.0)

as_flextable.tabulator: tabulator to flextable

Description

tabulator object can be transformed as a flextable with method as_flextable().

Usage

# S3 method for tabulator
as_flextable(
  x,
  separate_with = character(0),
  big_border = fp_border_default(width = 1.5),
  small_border = fp_border_default(width = 0.75),
  rows_alignment = "left",
  columns_alignment = "center",
  sep_w = 0.05,
  unit = "in",
  ...
)

Arguments

x

result from tabulator()

separate_with

columns used to sepatate the groups with an horizontal line.

big_border, small_border

big and small border properties defined by a call to fp_border_default() or fp_border().

rows_alignment, columns_alignment

alignments to apply to columns corresponding to rows and columns; see arguments rows and columns in tabulator().

sep_w

blank column separators'width to be used. If 0, blank column separators will not be used.

unit

unit of argument sep_w, one of "in", "cm", "mm".

...

unused argument

See Also

summarizor(), as_grouped_data()

Other as_flextable methods: as_flextable.gam(), as_flextable.glm(), as_flextable.grouped_data(), as_flextable.htest(), as_flextable.lm(), as_flextable.xtable(), as_flextable()

Examples

Run this code
# NOT RUN {
library(flextable)

set_flextable_defaults(digits = 2, border.color = "gray")

if(require("stats")){
  dat <- aggregate(breaks ~ wool + tension,
    data = warpbreaks, mean)

  cft_1 <- tabulator(x = dat,
                     rows = "wool",
    columns = "tension",
    `mean` = as_paragraph(as_chunk(breaks)),
    `(N)` = as_paragraph(
      as_chunk(length(breaks) ))
  )

  ft_1 <- as_flextable(cft_1, sep_w = .1)
  ft_1

  set_flextable_defaults(padding = 1, font.size = 9, border.color = "orange")
  ft_2 <- as_flextable(cft_1, sep_w = 0)
  ft_2

  set_flextable_defaults(padding = 6, font.size = 11,
                         border.color = "white", font.color = "white",
                         background.color = "#333333")
  ft_3 <- as_flextable(
    x = cft_1, sep_w = 0,
    rows_alignment = "center",
    columns_alignment = "right")
  ft_3
}

init_flextable_defaults()
# }

Run the code above in your browser using DataLab