GSK-Biostatistics / gto

gt in officeverse
https://gsk-biostatistics.github.io/gto/
Apache License 2.0
23 stars 1 forks source link

Suggestion: Add an option to "pos" to insert a blank line before (or after?) adding the gt table, so Word doesn't see it as an extension of the prior gt table #6

Open BorgeJorge opened 1 year ago

BorgeJorge commented 1 year ago

I'd love to use gto to export multiple data.frame and table snippets but I'd like to be able to manipulate them separately, type in notes between them afterwards, etc. I realize I can use officer functions to do this, but it'd be handy to have a "pos" option that'll insert, say, a line (using body_add_par?) with a single space before (or after?) adding the table.

Anyway, thanks, I'm loving the package!

thebioengineer commented 1 year ago

Thanks for the feedback! Since body_add_gt is intended to be an analog to body_add_flextable, I an hesitant to add this feature in directly.

If this is a regular thing you do, you could write a wrapper to achieve your goal. This might get you somewhat on your way:

body_add_gt_and_notes <- function(doc, gt, notes){
  # add notes, then add table, putting notes below the table
  doc <- doc |> 
   officer::body_add_par("") %>%
   officer::body_add_par(notes, pos = "after") |>
   gto::body_add_gt(gt, pos = "after")
}

I can also leave this issue open to see if additional folks would like this added in too.