Skip to contents

Split a flextable into a list of flextables whose columns fit within a given width (in inches). This is useful for paginating wide tables in Word or PowerPoint output.

Usage

split_columns(x, max_width, rep_cols = NULL, unit = "in")

Arguments

x

a 'flextable' object, see flextable-package to learn how to create 'flextable' object.

max_width

Maximum width for each page (in inches by default).

rep_cols

Columns to repeat on every page. Can be a character vector of column names or an integer vector of column positions. NULL (default) means no repetition. Repeated columns appear at the beginning of each page in the order specified.

unit

Unit for max_width, one of "in", "cm", "mm".

Value

A list of flextable objects. If no splitting is needed, a single-element list is returned.

Examples

ft <- flextable(head(mtcars))
ft_pages <- split_columns(ft, max_width = 5)
length(ft_pages)
#> [1] 2