Questions tagged [gtsummary]

Use this tag for questions about using the gtsummary package for data visualization in R.

{gtsummary} is an R package that creates presentation-ready summary and analytic tables. All package functions are fully documented on the {gtsummary} website, which also contains detailed tutorials.

Use the gtsummary tag on StackOverflow to ask questions about the usage of {gtsummary} functions, for example, how to use the customization features or inquiries on how to use custom functions within arguments.

To report bugs, please submit an issue on gtsummary's GitHub.

655 questions
9
votes
1 answer

How to sort or change rows order in a сharacteristic table column in the gtsummary package?

I'm trying to change rows order in a сharacteristic table column using function sort = list (stage ~ "alphanumeric ") in the tbl_summary () trial[c("trt", "age", "stage", "grade")] %>% tbl_summary(by = trt, sort = list (grade ~ "alphanumeric")).…
9
votes
1 answer

How to output {gtsummary} tables as images?

I am trying to output {gtsummary} tables (specifically tbl_regression() output) as images. I am using kableExtra::as_image() but the result is not very pretty. A reprex is below but I don't have the reputation to post an image. Is there a way to…
shortessay
  • 113
  • 1
  • 7
8
votes
1 answer

How to format the number of digits for categorical variables in 'gtsummary::tbl_summary'?

I am unable to figure out how to tell the tbl_summary function to display decimal places when summarizing categorical variables. It works quite well with continuous variables like 'mpg', but not for 'cyl'. library(tidyverse) library(gtsummary) #…
RockinRichi
  • 83
  • 1
  • 3
7
votes
2 answers

R, tbl_summary, treating continuous variables correctly

I am having a similar problem to what this user reported. Variables that are numeric and continuous are being treated as categorical. Lets just use the cars dataset as well so that we have something reproducible to work with. Lets say I simply…
Joe Crozier
  • 944
  • 8
  • 20
6
votes
1 answer

split frequency and percentage in tbl_summary in to two separate columns

I would to split the values of N and % into two separate columns ie, N and % columns library(gtsummary) trial %>% select(response, grade) %>% tbl_summary()
Magut
  • 151
  • 7
6
votes
1 answer

Best way to get LaTex output from tbl_summary object in gtsummary package

I'm trying to get a document publication-ready and am doing everything in LaTeX. However, I just now noticed that gtsummary doesn't yet support LaTeX output for its tables. I'm wondering what the best way is to nevertheless convert the HTML tables…
Parseltongue
  • 11,157
  • 30
  • 95
  • 160
6
votes
2 answers

regression models in r output table to word

I have been using sjplot to create a combined table. This creates a HTML table. I would like to make a table that can be exported to word. I have reviewed this post which discusses copy and pasting into word, but this alters the formatting of the…
sar
  • 182
  • 6
  • 26
5
votes
1 answer

Add multiple levels of headers to gtsummary regression table with many models

I am trying to generate multiple levels of headers for a gtsummary regression table containing regression models which should be grouped by year in the table. Here's a toy example: library(dplyr) library(gtsummary) library(purrr) set.seed(92922) df…
nicholas
  • 903
  • 2
  • 12
5
votes
1 answer

Adding a footnote to a single row label in a gtsummary table

I'm trying to add a footnote to a row label of a gtsummary table, but I can't figure out how to reference the exact cell I want. Intended output Usint the default trial dataset, I'd like to add a footnote to "Drug B" that reads "i.e.…
Andrea M
  • 2,314
  • 1
  • 9
  • 27
5
votes
1 answer

Is possible to do a table with two group by with tbl_summary in R?

I'm working with the mtcars database, and I'm using the tbl_summary function. What I'm trying to do is to have two group by's, first with the type of transmission and then with the number of cylinders, so I will have six columns in total for the…
Begdev
  • 79
  • 1
  • 7
5
votes
1 answer

Formatting group_header text when using tbl_stack from gtsummary

I am trying to use the tbl_stack function from the gtsummary package, but the output text from using the group_header argument looks too visually similar to the rest of the labels. Ideally I would like to format the text with either bold, underline,…
andrewsris
  • 65
  • 4
5
votes
1 answer

Save as_kable_extra (format = "latex") on file

I use as_kable_extra(table, format="latex"). This code gives me a chuck of latex codes, then I copy and paste then save it as a tex table. Can I save the latex code on R so that I can avoid copy and paste?
HSC
  • 129
  • 6
5
votes
2 answers

Grouping Rows in GTSummary

I am trying to group some rows/variables (both categorical and continuous) to help with the table readability in a large dataset. Here is the dummy dataset: library(gtsummary) library(tidyverse) library(gt) set.seed(11012021) # Create Dataset PIR…
Benjamin Moran
  • 109
  • 1
  • 8
5
votes
1 answer

How to add percentage to "unknown" in gtsummary

I have a continuous variable with a significant proportion of unknowns. My advisor is asking me to put the percentage next to it in the column. This reprex mimics what I am trying to do. library(tidyverse) library(gtsummary) trial %>% #…
Elliott Chinn
  • 117
  • 1
  • 8
5
votes
1 answer

How to use {gtsummary} package in r shiny app

Is it possible to render a table with {gtsummary} in a shiny app? library(gtsummary) # make dataset with a few variables to summarize iris2 <- iris %>% select(Sepal.Length, Sepal.Width, Species) # summarize the data with our package table1 <-…
TarJae
  • 72,363
  • 6
  • 19
  • 66
1
2 3
43 44