merge_h: Merge flextable cells horizontally

View source: R/merge_flextable.R

merge_hR Documentation

Merge flextable cells horizontally

Description

Merge flextable cells horizontally when consecutive cells have identical values. Text of formatted values are used to compare values.

Usage

merge_h(x, i = NULL, part = "body")

Arguments

x

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

i

row selector, see section Row selection with the i parameter in <Selectors in flextable>.

part

part selector, see section Part selection with the part parameter in <Selectors in flextable>. Value 'all' is not allowed by the function.

See Also

Other cell merging functions: merge_at(), merge_h_range(), merge_none(), merge_v()

Examples

library(flextable)

schedule <- data.frame(
  time = c("9h", "10h", "11h", "14h", "15h", "16h"),
  monday = c("Math", "Math", "French", "History", "Science", "French"),
  tuesday = c("English", "Math", "Art", "Math", "Math", "French"),
  wednesday = c("Science", "Math", "Science", "English", "English", "French"),
  stringsAsFactors = FALSE
)

ft <- flextable(schedule)
ft <- theme_box(ft)
ft <- merge_h(ft)
ft

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