Summarise a data.frame as gtsummary
with Dutch defaults. These objects are based on the gt
package by RStudio. To provide Certe style and compatibility with MS Word, use tbl_flextable()
to transform the gtsummary
object.
A column name (quoted or unquoted) in data
.
Summary statistics will be calculated separately for each level of the by
variable (e.g. by = trt
). If NULL
, summary statistics
are calculated using all observations. To stratify a table by two or more
variables, use tbl_strata()
List of formulas specifying variables labels,
e.g. list(age ~ "Age", stage ~ "Path T Stage")
. If a
variable's label is not specified here, the label attribute
(attr(data$age, "label")
) is used. If
attribute label is NULL
, the variable name will be used.
List of formulas specifying the number of decimal
places to round summary statistics. If not specified,
tbl_summary
guesses an appropriate number of decimals to round statistics.
When multiple statistics are displayed for a single variable, supply a vector
rather than an integer. For example, if the
statistic being calculated is "{mean} ({sd})"
and you want the mean rounded
to 1 decimal place, and the SD to 2 use digits = list(age ~ c(1, 2))
. User
may also pass a styling function: digits = age ~ style_sigfig
Arguments passed on to gtsummary::tbl_summary()
the language to use, defaults to Dutch
name to use for the first column
add the overall N using gtsummary::add_n()
add the p values gtsummary::add_p()
(tests will be determined automatcally)
add the confidence interval using gtsummary::add_ci()
add the overall statistics using gtsummary::add_overall()
decimal separator, defaults to dec_mark()
thousands separator, defaults to big_mark()
tbl_gtsummary()
creates a summary table with gtsummary::tbl_summary()
, to which different extra columns can be added e.g. with add_p = TRUE
and add_overall = TRUE
.
# These examples default to the Dutch language
iris |>
tbl_gtsummary()
#> Setting theme "language: nl"
#> Warning: The `quiet` argument of `set_gtsummary_theme()` is deprecated as of gtsummary
#> 2.0.0.
#> ℹ Argument has been ignored.
#> ℹ The deprecated feature was likely used in the certetoolbox package.
#> Please report the issue to the authors.
Karakteristiek
N = 1501
1 Mediaan (Q1 – Q3); n (%)
iris |>
tbl_gtsummary(Species, add_p = TRUE)
#> Setting theme "language: nl"
#> Setting theme "language: nl"
Karakteristiek
setosa
N = 501
versicolor
N = 501
virginica
N = 501
p-waarde2
1 Mediaan (Q1 – Q3)
2 Kruskal-Wallistoets
iris |>
tbl_gtsummary(Species, add_n = TRUE)
#> Setting theme "language: nl"
#> Setting theme "language: nl"
Karakteristiek
setosa
N = 501
versicolor
N = 501
virginica
N = 501
N
1 Mediaan (Q1 – Q3)
# support strata by providing
iris2 <- iris
iris2$Category <- sample(LETTERS[1:2], size = 150, replace = TRUE)
head(iris2)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species Category
#> 1 5.1 3.5 1.4 0.2 setosa B
#> 2 4.9 3.0 1.4 0.2 setosa B
#> 3 4.7 3.2 1.3 0.2 setosa A
#> 4 4.6 3.1 1.5 0.2 setosa A
#> 5 5.0 3.6 1.4 0.2 setosa A
#> 6 5.4 3.9 1.7 0.4 setosa A
iris2 |>
tbl_gtsummary(c(Category, Species))
#> Setting theme "language: nl"
#> Setting theme "language: nl"
setosa
N = 271
versicolor
N = 251
virginica
N = 251
setosa
N = 231
versicolor
N = 251
virginica
N = 251
1 Mediaan (Q1 – Q3)
# transform to flextable
# (formats to Certe style and allows rendering to Word)
iris |>
tbl_gtsummary(Species) |>
tbl_flextable()
#> Setting theme "language: nl"
#> Setting theme "language: nl"
#> [1] "<div class=\"tabwid\"><style>.cl-c0052cbc{}.cl-bfff3816{font-family:'Source Sans Pro';font-size:10pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(255, 255, 255, 1.00);background-color:transparent;}.cl-bfff3820{font-family:'Source Sans Pro';font-size:6pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(255, 255, 255, 1.00);background-color:transparent;position: relative;bottom:3pt;}.cl-bfff382a{font-family:'Source Sans Pro';font-size:9pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-bfff382b{font-family:'Source Sans Pro';font-size:5.4pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;position: relative;bottom:2.7pt;}.cl-c001bd3e{margin:0;text-align:center;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-c001bd48{margin:0;text-align:center;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-c001d8c8{width:1.742in;background-color:rgba(74, 100, 125, 1.00);vertical-align: middle;border-bottom: 2pt solid rgba(74, 100, 125, 1.00);border-top: 2pt solid rgba(74, 100, 125, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-c001d8d2{width:1.519in;background-color:rgba(74, 100, 125, 1.00);vertical-align: middle;border-bottom: 2pt solid rgba(74, 100, 125, 1.00);border-top: 2pt solid rgba(74, 100, 125, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-c001d8d3{width:1.742in;background-color:rgba(226, 231, 236, 1.00);vertical-align: top;border-bottom: 0.75pt solid rgba(255, 255, 255, 0.00);border-top: 0.75pt solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-c001d8d4{width:1.519in;background-color:rgba(226, 231, 236, 1.00);vertical-align: top;border-bottom: 0.75pt solid rgba(255, 255, 255, 0.00);border-top: 0.75pt solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-c001d8dc{width:1.742in;background-color:rgba(246, 247, 248, 1.00);vertical-align: top;border-bottom: 0.75pt solid rgba(255, 255, 255, 0.00);border-top: 0.75pt solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-c001d8e6{width:1.519in;background-color:rgba(246, 247, 248, 1.00);vertical-align: top;border-bottom: 0.75pt solid rgba(255, 255, 255, 0.00);border-top: 0.75pt solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-c001d8f0{width:1.742in;background-color:rgba(246, 247, 248, 1.00);vertical-align: top;border-bottom: 2pt solid rgba(74, 100, 125, 1.00);border-top: 0.75pt solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-c001d8f1{width:1.519in;background-color:rgba(246, 247, 248, 1.00);vertical-align: top;border-bottom: 2pt solid rgba(74, 100, 125, 1.00);border-top: 0.75pt solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-c001d8fa{width:1.742in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(255, 255, 255, 0.00);border-top: 0.75pt solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-c001d8fb{width:1.519in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(255, 255, 255, 0.00);border-top: 0.75pt solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.tabwid {\n font-size: initial;\n padding-bottom: 1em;\n}\n\n.tabwid table{\n border-spacing:0px !important;\n border-collapse:collapse;\n line-height:1;\n margin-left:auto;\n margin-right:auto;\n border-width: 0;\n border-color: transparent;\n caption-side: top;\n}\n.tabwid-caption-bottom table{\n caption-side: bottom;\n}\n.tabwid_left table{\n margin-left:0;\n}\n.tabwid_right table{\n margin-right:0;\n}\n.tabwid td, .tabwid th {\n padding: 0;\n}\n.tabwid a {\n text-decoration: none;\n}\n.tabwid thead {\n background-color: transparent;\n}\n.tabwid tfoot {\n background-color: transparent;\n}\n.tabwid table tr {\nbackground-color: transparent;\n}\n.katex-display {\n margin: 0 0 !important;\n}</style><table data-quarto-disable-processing='true' class='cl-c0052cbc'><thead><tr style=\"overflow-wrap:break-word;\"><th class=\"cl-c001d8c8\"><p class=\"cl-c001bd3e\"><span class=\"cl-bfff3816\">Karakteristiek</span></p></th><th class=\"cl-c001d8d2\"><p class=\"cl-c001bd3e\"><span class=\"cl-bfff3816\">setosa</span><span class=\"cl-bfff3816\"> </span><br><span class=\"cl-bfff3816\">N = 50</span><span class=\"cl-bfff3820\">1</span></p></th><th class=\"cl-c001d8d2\"><p class=\"cl-c001bd3e\"><span class=\"cl-bfff3816\">versicolor</span><span class=\"cl-bfff3816\"> </span><br><span class=\"cl-bfff3816\">N = 50</span><span class=\"cl-bfff3820\">1</span></p></th><th class=\"cl-c001d8d2\"><p class=\"cl-c001bd3e\"><span class=\"cl-bfff3816\">virginica</span><span class=\"cl-bfff3816\"> </span><br><span class=\"cl-bfff3816\">N = 50</span><span class=\"cl-bfff3820\">1</span></p></th></tr></thead><tbody><tr style=\"overflow-wrap:break-word;\"><td class=\"cl-c001d8d3\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">Sepal.Length</span></p></td><td class=\"cl-c001d8d4\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">5.0 (4.8 – 5.2)</span></p></td><td class=\"cl-c001d8d4\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">5.9 (5.6 – 6.3)</span></p></td><td class=\"cl-c001d8d4\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">6.5 (6.2 – 6.9)</span></p></td></tr><tr style=\"overflow-wrap:break-word;\"><td class=\"cl-c001d8dc\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">Sepal.Width</span></p></td><td class=\"cl-c001d8e6\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">3.4 (3.2 – 3.7)</span></p></td><td class=\"cl-c001d8e6\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">2.8 (2.5 – 3.0)</span></p></td><td class=\"cl-c001d8e6\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">3.0 (2.8 – 3.2)</span></p></td></tr><tr style=\"overflow-wrap:break-word;\"><td class=\"cl-c001d8d3\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">Petal.Length</span></p></td><td class=\"cl-c001d8d4\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">1.5 (1.4 – 1.6)</span></p></td><td class=\"cl-c001d8d4\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">4.4 (4.0 – 4.6)</span></p></td><td class=\"cl-c001d8d4\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">5.6 (5.1 – 5.9)</span></p></td></tr><tr style=\"overflow-wrap:break-word;\"><td class=\"cl-c001d8f0\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">Petal.Width</span></p></td><td class=\"cl-c001d8f1\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">0.2 (0.2 – 0.3)</span></p></td><td class=\"cl-c001d8f1\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">1.3 (1.2 – 1.5)</span></p></td><td class=\"cl-c001d8f1\"><p class=\"cl-c001bd48\"><span class=\"cl-bfff382a\">2.0 (1.8 – 2.3)</span></p></td></tr></tbody><tfoot><tr style=\"overflow-wrap:break-word;\"><td colspan=\"4\"class=\"cl-c001d8fa\"><p class=\"cl-c001bd3e\"><span class=\"cl-bfff382b\">1</span><span class=\"cl-bfff382a\">Mediaan (Q1 – Q3)</span></p></td></tr></tfoot></table></div>"
#> attr(,"class")
#> [1] "knit_asis"
#> attr(,"knit_cacheable")
#> [1] NA