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.

tbl_gtsummary(
  x,
  by = NULL,
  label = NULL,
  digits = 1,
  ...,
  language = "nl",
  column1_name = "Eigenschap",
  add_n = FALSE,
  add_p = FALSE,
  add_ci = FALSE,
  add_overall = FALSE,
  decimal.mark = dec_mark(),
  big.mark = big_mark()
)

Arguments

x

a data.frame

by

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()

label

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.

digits

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()

language

the language to use, defaults to Dutch

column1_name

name to use for the first column

add_n

add the overall N using gtsummary::add_n()

add_p

add the p values gtsummary::add_p() (tests will be determined automatcally)

add_ci

add the confidence interval using gtsummary::add_ci()

add_overall

add the overall statistics using gtsummary::add_overall()

decimal.mark

decimal separator, defaults to dec_mark()

big.mark

thousands separator, defaults to big_mark()

Details

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.

Examples

# 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
Sepal.Length 5.8 (5.1 – 6.4)
Sepal.Width 3.0 (2.8 – 3.3)
Petal.Length 4.4 (1.6 – 5.1)
Petal.Width 1.3 (0.3 – 1.8)
Species
    setosa 50.0 (33.3%)
    versicolor 50.0 (33.3%)
    virginica 50.0 (33.3%)
1 Mediaan (Q1 – Q3); n (%)
iris |> tbl_gtsummary(Species, add_p = TRUE) #> Setting theme "language: nl" #> Setting theme "language: nl"
Karakteristiek setosa
N = 50
1
versicolor
N = 50
1
virginica
N = 50
1
p-waarde2
Sepal.Length 5.0 (4.8 – 5.2) 5.9 (5.6 – 6.3) 6.5 (6.2 – 6.9)
Sepal.Width 3.4 (3.2 – 3.7) 2.8 (2.5 – 3.0) 3.0 (2.8 – 3.2)
Petal.Length 1.5 (1.4 – 1.6) 4.4 (4.0 – 4.6) 5.6 (5.1 – 5.9)
Petal.Width 0.2 (0.2 – 0.3) 1.3 (1.2 – 1.5) 2.0 (1.8 – 2.3)
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 = 50
1
versicolor
N = 50
1
virginica
N = 50
1
N
Sepal.Length 5.0 (4.8 – 5.2) 5.9 (5.6 – 6.3) 6.5 (6.2 – 6.9) 150
Sepal.Width 3.4 (3.2 – 3.7) 2.8 (2.5 – 3.0) 3.0 (2.8 – 3.2) 150
Petal.Length 1.5 (1.4 – 1.6) 4.4 (4.0 – 4.6) 5.6 (5.1 – 5.9) 150
Petal.Width 0.2 (0.2 – 0.3) 1.3 (1.2 – 1.5) 2.0 (1.8 – 2.3) 150
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"
Karakteristiek
A
B
setosa
N = 27
1
versicolor
N = 25
1
virginica
N = 25
1
setosa
N = 23
1
versicolor
N = 25
1
virginica
N = 25
1
Sepal.Length 5.0 (4.8 – 5.3) 5.8 (5.6 – 6.3) 6.3 (6.1 – 6.9) 5.0 (4.6 – 5.1) 6.0 (5.6 – 6.2) 6.5 (6.4 – 7.2)
Sepal.Width 3.4 (3.1 – 3.6) 2.8 (2.6 – 3.0) 2.8 (2.7 – 3.0) 3.4 (3.2 – 3.8) 2.9 (2.5 – 3.0) 3.0 (2.9 – 3.2)
Petal.Length 1.5 (1.4 – 1.6) 4.2 (4.0 – 4.5) 5.4 (5.1 – 5.6) 1.4 (1.4 – 1.6) 4.5 (4.0 – 4.7) 5.7 (5.3 – 6.0)
Petal.Width 0.2 (0.2 – 0.2) 1.3 (1.2 – 1.4) 2.0 (1.8 – 2.1) 0.2 (0.2 – 0.4) 1.4 (1.3 – 1.5) 2.1 (1.8 – 2.3)
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-e728aab0{}.cl-e72299d6{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-e72299e0{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-e72299ea{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-e72299f4{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-e7251652{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-e7251666{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-e7253222{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-e725322c{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-e7253236{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-e7253240{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-e7253241{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-e725324a{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-e7253254{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-e7253255{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-e7253268{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-e7253269{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-e728aab0'><thead><tr style=\"overflow-wrap:break-word;\"><th class=\"cl-e7253222\"><p class=\"cl-e7251652\"><span class=\"cl-e72299d6\">Karakteristiek</span></p></th><th class=\"cl-e725322c\"><p class=\"cl-e7251652\"><span class=\"cl-e72299d6\">setosa</span><span class=\"cl-e72299d6\"> </span><br><span class=\"cl-e72299d6\">N = 50</span><span class=\"cl-e72299e0\">1</span></p></th><th class=\"cl-e725322c\"><p class=\"cl-e7251652\"><span class=\"cl-e72299d6\">versicolor</span><span class=\"cl-e72299d6\"> </span><br><span class=\"cl-e72299d6\">N = 50</span><span class=\"cl-e72299e0\">1</span></p></th><th class=\"cl-e725322c\"><p class=\"cl-e7251652\"><span class=\"cl-e72299d6\">virginica</span><span class=\"cl-e72299d6\"> </span><br><span class=\"cl-e72299d6\">N = 50</span><span class=\"cl-e72299e0\">1</span></p></th></tr></thead><tbody><tr style=\"overflow-wrap:break-word;\"><td class=\"cl-e7253236\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">Sepal.Length</span></p></td><td class=\"cl-e7253240\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">5.0 (4.8 – 5.2)</span></p></td><td class=\"cl-e7253240\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">5.9 (5.6 – 6.3)</span></p></td><td class=\"cl-e7253240\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">6.5 (6.2 – 6.9)</span></p></td></tr><tr style=\"overflow-wrap:break-word;\"><td class=\"cl-e7253241\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">Sepal.Width</span></p></td><td class=\"cl-e725324a\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">3.4 (3.2 – 3.7)</span></p></td><td class=\"cl-e725324a\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">2.8 (2.5 – 3.0)</span></p></td><td class=\"cl-e725324a\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">3.0 (2.8 – 3.2)</span></p></td></tr><tr style=\"overflow-wrap:break-word;\"><td class=\"cl-e7253236\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">Petal.Length</span></p></td><td class=\"cl-e7253240\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">1.5 (1.4 – 1.6)</span></p></td><td class=\"cl-e7253240\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">4.4 (4.0 – 4.6)</span></p></td><td class=\"cl-e7253240\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">5.6 (5.1 – 5.9)</span></p></td></tr><tr style=\"overflow-wrap:break-word;\"><td class=\"cl-e7253254\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">Petal.Width</span></p></td><td class=\"cl-e7253255\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">0.2 (0.2 – 0.3)</span></p></td><td class=\"cl-e7253255\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">1.3 (1.2 – 1.5)</span></p></td><td class=\"cl-e7253255\"><p class=\"cl-e7251666\"><span class=\"cl-e72299ea\">2.0 (1.8 – 2.3)</span></p></td></tr></tbody><tfoot><tr style=\"overflow-wrap:break-word;\"><td colspan=\"4\"class=\"cl-e7253268\"><p class=\"cl-e7251652\"><span class=\"cl-e72299f4\">1</span><span class=\"cl-e72299ea\">Mediaan (Q1 – Q3)</span></p></td></tr></tfoot></table></div>" #> attr(,"class") #> [1] "knit_asis" #> attr(,"knit_cacheable") #> [1] NA