Skip to content

spread_first_col outside of as_flextable #718

@r2evans

Description

@r2evans

(I think this is a FR, but a bug.)

I have an existing flextable chain that produces a good table. From there, I have been manually (in Word) shifting the first column to a row-group header: add a row above, merge the cells, copy the value in, then eventually delete the first column.

I think this is what as_flextable(spread_first_col=TRUE) is supposed to enable. However, I have a regular flextable() on the data. I have no need to tabulate or summarize it, that's already been done, so I don't need (I think) summarizor() or tabulator(), therefore I cannot use as_flextable().

In the end, I'm hoping for something like this using spread_first_col=TRUE, and I can't figure out how to do it with a vanilla frame.

Image
library(dplyr)
library(flextable)
relocate(mtcars, cyl, .before = everything()) |>
  arrange(cyl) |>
  flextable() |>
  save_as_docx(path="mytable.docx")

I think in the interim I could hand-jam using merge_h_range() to insert rows, merge the columns, etc. Is there a better way to do that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions