flextable (version 0.5.6)

merge_v: Merge flextable cells vertically

Description

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

Usage

merge_v(x, j = NULL, target = NULL, part = "body")

Arguments

x

flextable object

j

column to used to find consecutive values to be merged.

target

columns names where cells have to be merged.

part

partname of the table where merge has to be done.

See Also

Other flextable merging function: merge_at, merge_h_range, merge_h, merge_none

Examples

Run this code
# NOT RUN {
ft_merge <- flextable(mtcars)
ft_merge <- merge_v(ft_merge, j = c("gear", "carb"))
ft_merge

data_ex <- structure(list(srdr_id = c(
  "175124", "175124", "172525", "172525",
  "172545", "172545", "172609", "172609", "172609"
), substances = c(
  "alcohol",
  "alcohol", "alcohol", "alcohol", "cannabis",
  "cannabis", "alcohol\n cannabis\n other drugs",
  "alcohol\n cannabis\n other drugs",
  "alcohol\n cannabis\n other drugs"
), full_name = c(
  "TAU", "MI", "TAU", "MI (parent)", "TAU", "MI",
  "TAU", "MI", "MI"
), article_arm_name = c(
  "Control", "WISEteens",
  "Treatment as usual", "Brief MI (b-MI)", "Assessed control",
  "Intervention", "Control", "Computer BI", "Therapist BI"
)), row.names = c(
  NA,
  -9L
), class = c("tbl_df", "tbl", "data.frame"))
ft <- flextable(data_ex)
ft <- theme_box(ft)
merge_v(ft, j = "srdr_id",
  target = c("srdr_id", "substances"))
# }

Run the code above in your browser using DataLab