Skip to contents

Adds to a flextable from hv_man_table() what hv_man_table_save() writes around it in Word, so a report can show the same table in HTML: the footnote marks in the header (an asterisk on each No. column, a dagger on the statistic columns), the footnotes, and the abbreviation key. In Word the notes are paragraphs below the table; here they are footer lines, since HTML has no page to put them on.

Usage

hv_man_table_display(ft, footnotes = NULL, abbreviations = NULL)

Arguments

ft

A flextable, from hv_man_table().

footnotes

Optional named list, symbol -> footnote text, exactly as for hv_man_table_save(). Omit it for the table's own footnotes; NULL shows none. A note's text may carry ^2^ or ~2~ markup, as a label does.

abbreviations

Optional named character vector, abbreviation -> definition, exactly as for hv_man_table_save(): shown as one "Key:" line, sorted by abbreviation. A table showing a confidence interval adds CI unless you define it. A name or definition may carry ^2^ or ~2~ markup, as a label does.

Value

ft with the header marks and the footer lines added, for display.

Details

The notes follow the table's style: a manuscript table's notes begin with the plain symbol and use the submissions' wording, as they do in the saved file. A manuscript table sets no font, so in HTML it takes the font and size of the page around it, as in Word it takes the document's.

The one deliberate difference is the "Variable" column hv_tbl_summary()'s show_variable adds: the display keeps it, as the report view, while the saved table never has it.

The marks, the note text and the key come from the same internal code the saver uses, so the displayed table and the saved one cannot disagree. footnotes resolves the same way too: left out, it is the footnote block the table carries from hv_tbl_summary(), or hv_man_footnotes() for any other flextable. A double dagger hv_man_table() put on a Fisher exact p-value is already on its cell and is footnoted, not marked again in the header.

The result is for display only. Save the flextable you passed in, not the result: its notes are rows inside the table, which the Word layout forbids, and hv_man_table_save() refuses it.

Common mistakes

"ft is a display copy from hv_man_table_display() ..." You passed the result to hv_man_table_save(). Keep the flextable from hv_man_table() for saving and display a copy: hv_man_table_save(ft, file) and hv_man_table_display(ft).

"The table marks cells with ..." The table has a Fisher exact p-value marked with a double dagger, and footnotes leaves it unexplained or files another note under it. Omit footnotes, or add the entry the error names.

Different notes in the report and in Word. Pass the same footnotes and abbreviations to both calls.

See also

hv_man_table_save(), which writes the same marks and notes to Word. hv_man_footnotes() for the default footnotes.

Examples

ft <- hv_man_table(hv_tbl_summary(
  gtsummary::trial, by = "trt",
  groups = list(Demography = c("age", "grade")),
  continuous = "age", categorical = "grade", compare = "none"
))
hv_man_table_display(ft, abbreviations = c(SD = "standard deviation"))

Characteristic

Variable

No.*

Overall
N = 200†

No.

Drug A
N = 98†

No.

Drug B
N = 102†

Demography

Age

age

189

47 [33, 63]

91

46 [32, 63]

98

48 [34, 63]

Grade

grade

I

200

68 (34)

98

35 (36)

102

33 (32)

II

200

68 (34)

98

32 (33)

102

36 (35)

III

200

64 (32)

98

31 (32)

102

33 (32)

* Number of non-missing values.

† No. (%) or Median [15th, 85th percentiles].

Key: SD, standard deviation