gtsummary | Presentation-Ready Data Summary and Analytic Result Tables | Data Visualization library
kandi X-RAY | gtsummary Summary
kandi X-RAY | gtsummary Summary
The {gtsummary} package provides an elegant and flexible way to create publication-ready analytical and summary tables using the R programming language. The {gtsummary} package summarizes data sets, regression models, and more, using sensible defaults with highly customizable capabilities.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of gtsummary
gtsummary Key Features
gtsummary Examples and Code Snippets
Community Discussions
Trending Discussions on gtsummary
QUESTION
i'm having the following problem:
Context:
I'm using gtsummary
to explore frequencies in a dataframe using cross variables.
So that i have a main variable tobgp
and its cross by multiple variables like agegp
and algp
Attempt:
this is what i've done so far. Using the esoph
data from the package The R Datasets Package (datasets).
ANSWER
Answered 2022-Mar-28 at 15:29you are pretty close and only needed a few modifications. the major change is adding in an lapply()
to loop through the vars
input to create a list of tbl_summary
objects. Then I create the tab spanner names from the inputs of vars
and append the t0
table to the list created by the lapply()
. then you can pass tlist2
to tbl_merge()
with the names created with tabspannername
to dynamically label the tables.
QUESTION
I've just discovered that add_nevent in gtsummary can have the option location = "level". I am rapt! But I would like it to have a percentage as well. I've tried adding statistic = "{n}({p}%)" but nothing changes.
Here is my code:
...ANSWER
Answered 2022-Mar-22 at 01:53After adding the N and N event, you can use the modify_table_body()
function to calculate the event rate. Example below!
QUESTION
ANSWER
Answered 2022-Mar-11 at 13:49You'll want to use the bstfun::add_variable_grouping()
function (https://www.danieldsjoberg.com/bstfun/reference/add_variable_grouping.html).
Example below!
QUESTION
I'm using gtsummary::tbl_uvregression to construct a univariate regression table modeled with geepack::geeglm.
Some variables contain NA values that are breaking the GEE models in the table.
x There was an error constructing model
geepack::geeglm(formula = tts_participant ~ omb_race, data = ., family = poisson, id =
School Name, corstr = "independence", scale.fix = TRUE)
See error below. Error inmutate_cols()
: ! Problem withmutate()
columnmodel
. imodel = map(...)
. x Error in geese.fit(xx, yy, id, offset, soffset, w, waves = waves, zsca, : nrow(zsca) and length(y) not match Caused by error: ! Error in geese.fit(xx, yy, id, offset, soffset, w, waves = waves, zsca, : nrow(zsca) and length(y) not match
You would generally set data = na.omit(data) for geepack::geeglm. However, I only want to remove NAs for the variables that I'm looking at in the table. na.action = na.omit does not work. I would like to avoid computing a gtsummary::tbl_uvregression table for each individual variable.
How do I instruct tbl_uvregression to remove the NAs only for the specific model being generated. Here is my attempt:
...ANSWER
Answered 2022-Feb-09 at 16:06The geepack::geeglm()
is funny how it doesn't handle the NA values for us. When I've come across this, I write a small wrapper function for geeglm()
that deletes the missing values before passing to geeglm()
. Example below! Happy Programming!
QUESTION
I am using tbl_summary() to summarize clinical characteristics of a patient cohort.
I have a patient group and a control group. My problem is that I have more variables for the patient group (blood counts etc.) that are not available for the control group.
Example data:
...ANSWER
Answered 2022-Jan-14 at 09:37It seems that you can't achieve the desired results only by using the arguments provided by the function (e.g. missing
and missing_text
arguments). You have to locally modify the list object.
QUESTION
I feel like I am missing something easy. Fingers crossed thats it.
Im trying to produce tables using gtsummary and flextable in officedown. I'm using the yaml options from the "Advanced word document" template in officedown.
Below is my code. The first 2 tables have the captions underneath and the third is on top, as it should be!
...ANSWER
Answered 2021-Dec-15 at 08:35Not an expert in flextable
and officedown
. But one option which worked for me was to set the position of the table captions for the R Markdown document via
knitr::opts_chunk$set(tab.topcaption = TRUE)
.
Full reproducible code:
QUESTION
I would want to add decimals for the percentage column only
#Separate columns library(gtsummary) library(tidyverse)
...ANSWER
Answered 2021-Dec-07 at 18:26You can conditionally add a digits=
value depending on whether we're summarizing the percentage or the counts. Example below!
QUESTION
ANSWER
Answered 2021-Nov-22 at 21:20I could not reproduce your code as some datasets are missing.
Below an example with various method to add header rows.
QUESTION
I am trying to print a list of HTML tables, but for some reason when I knit the document, I get the raw HTML code for output instead of the rendered table. Example:
...ANSWER
Answered 2021-Nov-22 at 20:57Consider using results = "asis"
in the r
chunk and then instead of print
use knitr::knit_print
QUESTION
Your help is most appreciated to include p-values for gtsummary::tbl_regression
function in scientific notation. I am using big data and it would be really useful to show 3 decimal points for p-values > 0.001 and scientific notation for p-values <0.001.
A representative example
...ANSWER
Answered 2021-Nov-04 at 19:22You can define your own function for the p-value format:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gtsummary
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page