atorus-research / pharmaRTF

Enhanced RTF wrapper written in R for use with existing R tables packages such as huxtable or GT

Home Page:https://atorus-research.github.io/pharmaRTF/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About column name in RTF

kaigu1990 opened this issue · comments

Hi,

The pharmaRTF package is so good to creat RTF file, but I have a query that what's the reason put the column names in header. According to RTF in clinical trials, we usually put the whole table including column names in the RTF body part, certainly I'm not familiar with RTF.

I'm looking for some solutions to creat RTF instead of SAS in R

Thanks!

Hi @kaigu1990!

The short answer here is simplicity. Clinical reports often go on for numerous pages. Document headers give the RTF document a built in method to repeat content from page to page without concerning yourself with the body of the table.

If we wanted to keep the headers attached within the body of the document, we'd have to iterate the table output repeatedly from page to page and draw assumptions about font size, the number of lines that can fit on a single page, the height of the footers. Beyond lines, do individual cells wrap their text? Because that pushes each of the next lines down lower.

In short, this greatly heightens the complexity. By grabbing the column headers and inserting them directly into the document header, we eliminate this burden altogether.

This does make me realize that we should have an option to prevent this. Intuitively, it would be like so:

ht <- huxtable::as_hux(mtcars,  add_colnames=TRUE)
width(ht) <- 1.5

doc <- pharmaRTF::rtf_doc(ht, titles=list(hf_line("Some title")), header_rows=0)

write_rtf(doc, file="test.rtf")

By specifying header_rows=0 ideally this would suppress the column headers from being extracted into the document header. We'll pursue making this update.

Hi,
Thank you for your wonderful answer to let me know the advantage of keeping column headers in document header. And the option is also very convenient when some tables are not long in some reports.
I‘m looking forward to your update!

Cheers,
Kai

Hello @kaigu1990,
We have submitted pharmaRTF 0.1.1 to CRAN that has support for removing column headers. Setting the header_rows attribute to 0 will suppress their output in the RTF document. It's working its way though the CRAN system check but it is available on GitHub now