split_columns: Split a flextable into pages by columns

View source: R/splitters.R

split_columnsR Documentation

Split a flextable into pages by columns

Description

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.

See Also

Other row and column operations: add_body(), add_body_row(), add_footer(), add_footer_lines(), add_footer_row(), add_header(), add_header_lines(), add_header_row(), delete_columns(), delete_part(), delete_rows(), paginate(), separate_header(), set_header_footer_df, set_header_labels(), split_rows(), split_to_pages()

Examples

ft <- flextable(head(mtcars))
ft_pages <- split_columns(ft, max_width = 5)
length(ft_pages)

flextable documentation built on June 2, 2026, 9:08 a.m.