Skip to content

Releases: ddsjoberg/gtsummary

gtsummary 1.3.5

30 Sep 14:03
Compare
Choose a tag to compare

New Functionality

  • New summary type continuous2 allows adding labelled statistic rows to tables in tbl_summary() and tbl_svysummary(). You can report several lines of statistics with this type. (#620)

    • The all_continuous() function now selects summary types continuous and continuous2 by default.
    • Added all_continuous2() function for selecting summary type continuous2 exclusively.
    • Added theme_gtsummary_continuous2() to make continuous2 the default summary type for all continuous variables.
  • New function add_glance_source_note() adds the statistics returned in broom::glance() as a source note on a tbl_regression() (#434)

  • Exporting the modify_table_header() function, which is an advanced-use function used to make modifications to the .$table_header object to update printing instructions for the gtsummary object.

  • Added two custom tidiers for use in tbl_regression() and tbl_uvregression(). (#635)

    • tidy_standardize() returns standardized coefficients using the {effectsize} package
    • tidy_bootstrap() gives bootstrapped parameter estimates, calculated using the {parameters} package

Bug Fixes

  • Bug fix where estimate_fun= and pvalue_fun= were not being passed to tbl_regression() in tbl_uvregression()

  • There was an environments bug when evaluating the LHS of the formula inputs. In some complex situations, a stored character vector of column names could not properly evaluate (#604)

  • Fixed style_ratio() bug where there were rounding errors near one (#651)

  • Fixed style_sigfig() bug where there were rounding errors near thresholds (#638)

  • Adding the footnote from the stat columns describing the statistics presented to the overall column (#643)

Other Updates

  • Refresh of vignettes to use recently released functions (#649)

  • Moved the nevent column to after the N column when add_nevent() is called on a tbl_regression() object (#439)

  • gtsummary themes updates

    • Add theme_gtsummary_mean_sd() theme to report mean and SD by default and use t-tests and ANOVA in add_p() (#654)
    • Added first draft of the NEJM theme
    • Added the mid-point decimal separator for the Lancet theme

gtsummary 1.3.4

27 Aug 19:31
6019783
Compare
Choose a tag to compare
  • Added a copy of tidyselect's where() function to allow users to use predicate select helpers (#632)

  • Fixed tbl_cross() bug where function defaulted to 'column' when margin = NULL. Now it defaults to display no margins when NULL. (#624)

  • Changed default of tbl_survfit() missing argument from '\U2014' (em dash) to NULL (CRAN issue). Em dash is still displayed by default in tables but it is set later in function.

gtsummary 1.3.3

11 Aug 18:30
2c9060e
Compare
Choose a tag to compare

New Functions

  • The {flextable} has graduated from Experimental status! Introducing as_flex_table(), which replaces as_flextable(). The updated function includes improvements to the default aesthetics of the tables, and improved consistency for spanning header rows.

  • Added tbl_svysummary() function to summarize complex and weighted survey designs. tbl_svysummary is now its own class that works with add_n(), add_p(), add_q(), add_stat_label(), add_overall(), inline_text(), tbl_merge() and tbl_stack() (#460).

  • The family of tbl_survfit() functions has been greatly expanded!

    • tbl_survfit.survfit(), tbl_survfit.list(), and tbl_survfit.data.frame() have been added that accept a single survfit object, list of survfit objects, or a data frame for more flexible creation of univariate survival tables.
    • add_p.tbl_survfit(), add_n.tbl_survfit(), add_nevent.tbl_survfit() have been added to include additional information in tbl_survfit() tables.
  • Adding as_hux_table() after the huxtable 5.0.0 release.

  • Added show_header_names() function to assist when updating table headers, footnotes, and spanning headers. The function prints the current underlying column names along with their labels easing the process of identifying the column names needed to make updates. (#539)

  • Added a language theme, theme_gtsummary_language() for translating tables into Spanish, French, Portuguese, German, Chinese (Traditional and Simplified), Hindi, Marathi, Gujarati, Japanese and Swedish (#511)

  • Added style_number() function which allows for granular control of how numbers are formatted throughout the package. The style_percent(), style_pvalue(), style_sigfig(), and style_ratio() functions have been updated to use style_number() in the background. The implication is that users can now control how every number in a gtsummary table appears. For example, formatting can be updated to use the comma as the decimal mark and also specify the big mark using the gtsummary themes. (#458)

User-facing Updates

  • Added support for competing risk cumulative incidence estimates to tbl_survfit() (#64, #448)

  • Updated API for set_gtsummary_theme(). Users no longer need call set_gtsummary_theme(theme_gtsummary_journal()); rather, they call theme_gtsummary_journal(). Each built-in theme now has an argument set_theme = TRUE. When FALSE, the theme function will invisibly return the named list the theme elements, and the theme will not be set. (#522)

  • Users can now specify how many decimal places to round statistics for categorical variables in tbl_summary(), e.g. 45 / 100 (45.0%). (#458)

  • Added the 'The Lancet' theme to theme_gtsummary_journal()

  • Updated the handling for arguments that accept functions to allow users to pass anonymous functions using the tidyverse shortcut notation, e.g. ~style_pvalue(.x, digits = 2).

  • The header for the tbl_stack(group_header=) column is now integrated into a typical gtsummary framework, meaning that all standard functions can be executed on it, e.g. modify_header() for non-gt output.

  • Added type= argument to add_global_p(), and added include= and keep= arguments to add_global_p.tbl_uvregression() (#554)

Internal Updates

  • Updated add_n() internals to be more efficient without recalculating statistics previously saved in tbl_summary()

  • {survival} package moved from Imports to Suggests

  • The add_overall() function is now a method function, and add_overall.tbl_summary and add_overall.tbl_svysummary added (#460).

  • Updated the variable labels for age and marker in the trial dataset.

  • Removed large *.gif files out of the package to reduce build size (#485)

Bug Fixes

  • Fixed bug where source note was not made smaller font size with compact theme when table was printed with {flextable} (#584)

  • Bug fix for tbl_summary() when a data frame contained an ordered factor column (#567)

  • Bug fix when only categorical summary statistics were requested for continuous variables in tbl_summary() and tbl_svysummary() (#528)

  • Bug fix when named list of {gtsummary} objects is passed to tbl_merge(x=) (#541)

  • Bug fix when for tbl_uvregression() when adjustment variables were included in formula = "{y} ~ {x} + age". The adjustment variables were being printed in the resulting table. (#555)

Breaking Changes

  • All lifecycle::deprecate_warn() have been upgraded to lifecycle::deprecate_stop() for <= v1.2.0 (released Aug 2019)

  • Removing as_flextable() and replacing with as_flex_table() due to a name conflict with flextable::as_flextable (#462)

gtsummary 1.3.2

14 Jun 12:35
Compare
Choose a tag to compare
  • Now returning all columns from broom::tidy() in .$table_body() (#516)

  • tbl_stack() now accepts a named list of gtsummary tables when using the group_header= argument (#524)

  • add_p.tbl_summary() bug fix for Wilcoxon rank-sum p-value calculation introduced in the last release (#525)

  • Delaying the release of as_huxtable() until the next {huxtable} release.

gtsummary 1.3.1 (2020-06-02)

03 Jun 01:51
e15ff6f
Compare
Choose a tag to compare

New Functions

  • Introducing themes in {gtsummary}. Use the function set_gtsummary_theme() to set new themes, and review the themes vignette for details on setting and creating personalized themes. (#424)

  • New functions modify_footnote() and modify_spanning_header() give users control over table footnotes and spanning headers. (#464)

  • Introducing as_huxtable()! The function converts gtsummary objects to {huxtable} objects. {huxtable} supports indentation, footnotes, and spanning headers with Word, HTML, and PDF output. (#469)

  • New function add_stat()! Add a new column of any statistic to a tbl_summary() table (#495)

User-facing Updates

  • The following columns in tbl_summary() are now available to print for both continuous and categorical variables: total number of observations {N_obs}, number of missing observations {N_miss}, number of non-missing observations {N_nomiss}, proportion of missing observations {p_miss}, proportion of non-missing observations {p_nomiss}. (#473)

  • Improved appearance of default as_flextable() output (#499)

  • Added tbl_cross(margin=) argument to control which margins are shown in the output table. (#444)

  • The missing values are now included in the calculation of p-values in tbl_cross().

  • Messaging about statistical methods used has been added for add_global_p(), add_q(), and combine_terms(). (#471)

  • Added include= argument to tbl_summary(). The preferred syntax for p-values with correlated data is now tbl_summary(..., include = -group_var) %>% add_p(group = group_var). The group variable is now no longer removed from the table summary. (#477)

  • add_stat_label() function updated with location= and label= arguments to change the location of the statistic labels and to modify the text of the labels. location = "row" is now the default. (#467)

  • tbl_stack() function added the group_header= argument that groups the stacked tables and adds a horizontal header row between them. (#468)

  • Updated handling for interaction terms in tbl_regression(). Interaction terms may now be specified in the show_single_row= and label= arguments. (#451, #452)

Internal Updates

  • Improved error messaging when invalid statistics are requested in tbl_summary(statistic=) (#502)

  • All columns in as_tibble() are now styled and converted to character. Previously, styling was applied to most columns, but there were a few that relied on default printing for the type of underlying data. This was ok to rely on this default behavior for as_kable(), but with the introduction of as_flextable() we needed to style and format each column to character. Potential to break some code in edge cases. (#493)

  • Handling of passed custom p-value functions in add_p.tbl_summary() has been improved with more careful handling of the environments from which the functions were passed. Other related updates were also made:

    • Users may pass their custom p-value function as a quoted string or bare.
    • The basic functions for calculating p-values, such as t.test() can now be passed directly e.g. test = age ~ t.test. We now perform a check match check for functions passed. If it is passed, we replace it with our internal version that returns the p-value and assigns the test name.
    • If a user passes a custom function, and it's not the proper form (i.e. a named list return object) AND the function returns a single numeric value, we assume that is the p-value and it's added to the gtsummary table.
  • Updated the gtsummary core script, utils-gtsummary_core.R, to refer to all non-base R functions with the pkg:: prefix, so other packages that copy the file don't need to import the same functions as {gtsummary} in the NAMESPACE. Now they just need to depend on the same packages. (#454)

Bug Fixes

  • Bug fix for inline_text.tbl_summary() when categorical variable contained levels with empty strings. There is still an issue if a user tries to select the empty string, however.

  • Fixed bug where some variables in tbl_cross() defaulted to dichotomous instead of showing as categorical (#506)

  • Bug fix when using a tbl_summary(by=) with missing observations in by= followed by add_overall()

  • Bug fix where values ">0.9" were incorrectly made bold using bold_p(). (#489)

  • Bug fix for as_flextable(). (#482)

    • Added a formatting function to all numeric columns to force conversion to character.
    • Spanning headers were being printed in alphabetical order! Update to preserve the ordering.

gtsummary 1.3.0

17 Apr 13:39
Compare
Choose a tag to compare

New Functions

  • Introducing tbl_cross(), add_p.tbl_cross(), and inline_text.tbl_cross()! Easily construct cross tabulations of two variables.

  • Introducing tbl_survfit() and inline_text.tbl_survfit()! These will eventually replace tbl_survival(), which will no longer be encouraged. The new functions follow the structural guidelines of a {gtsummary} object and can be merged and stacked with any over {gtsummary} object (#280)

  • Introducing as_flextable()! The function converts gtsummary objects to {flextable} objects, which is a great option when using R markdown with Microsoft Word output. {flextable} supports indentation, footnotes, and spanning headers with Word, HTML, and PDF output.

  • Introducing as_kable_extra()! The function converts gtsummary objects to {kableExtra} objects. {kableExtra} supports indentation, footnotes, and spanning headers with HTML and PDF output. (#394)

User-facing Updates

  • Updated default print engine for {gtsummary} objects. {gt} is the default printer for the R console and R markdown documents with HTML output. PDF, RTF, and Word output default to using {kable} with a note referring users to a new vignette explaining why {gt} was not used. (#395, #396)

  • Updated add_p() custom p-value description to NOT require double escape characters for quotation marks (#361)

  • Created structure and enumerated list of unit tests each vetted model must pass, and added the tests (#383)

Internal Updates

  • Each gtsummary object has an associated .$table_header. The code needed to print a table with either gt or kable was previously a mix of information stored in the table_header, and code manually added to the gt_calls or kable_calls object. Now, all the information needed to print a table is stored in table_header. This has the advantage that any updates to the printing will now require an update to table_header only, and we no longer need to update the tibble, kable and gt calls. (#412, #414)

  • The {gt} package is now released on CRAN, and we've updated to depend on the CRAN version instead of the version on GitHub. This also resulted in significant updates throughout the documentation and code. For example, we no longer provide instructions for installing {gt}, or include internal checks if {gt} is installed. (#420)

  • Several functions have been made general, and may now be applied to any {gtsummary}-like object. Functions updated are add_q(), bold_p(), sort_p(), tbl_merge(), tbl_stack(), bold_labels(), bold_levels(), italicize_labels(), and italicize_levels(). (#434, #429, #373)

  • In tbl_regression() we previously printed the estimate, confidence interval, and p-value for all models. But some models don't have associated methods for calculating the p-value or the confidence intervals. In this update, we now print the p-value if tidy() returns a "p.value" column. Similarly, the confidence interval is printed if tidy() returns "conf.low" and "conf.high" columns. (#391, #404)

Bug Fixes

  • Bug fix when data frame passed to tbl_summary() with a single column (#389)

  • In tbl_summary() passing an ordered factor in the by= argument no longer causes as error. (#453)

gtsummary 1.2.6

13 Feb 16:32
Compare
Choose a tag to compare
  • Bug fix for random effects regression model where coefficients were not exponentiated when requested. Using broom.mixed::tidy() rather than broom::tidy() resolved issue.

gtsummary 1.2.5

12 Feb 01:18
Compare
Choose a tag to compare

Documentation

  • Updated documentation and README to improve readability, added more cross-linking across pages, added search terms to help users find our package, and added gif demonstrations (#340)

  • README images now build differently for website vs GitHub markdown to accommodate different output formats

Breaking changes

  • Removed deprecated fmt*_() and cols_label_summary() functions (#365)

  • Functions tbl_summary_() and add_p_() have been deprecated because the by= and group= arguments now accept strings (#250)

Syntax

  • Package-wide update allowing arguments that accept variable names to accept bare/symbol inputs, character inputs, stored character inputs, and tidyselect helpers. When passing a single variable, the vars() function wrapper is no longer required. (#250)

    tbl_summary(trial, label = age ~ "NEW LABEL")) 
    tbl_summary(trial, label = "age" ~ "NEW LABEL")) 
    tbl_summary(trial, label = c("age", "trt") ~ "NEW LABEL")) 
    tbl_summary(trial, label = c(age, trt) ~ "NEW LABEL")) 
    tbl_summary(trial, label = vars(age, trt) ~ "NEW LABEL")) 
    tbl_summary(trial, label = vars(everything(), -age, -trt) ~ "NEW LABEL")) 
     
    age_column = "age" 
    tbl_summary(trial, label = age_column ~ "NEW LABEL")) 
    tbl_summary(trial, label = vars(age_column) ~ "NEW LABEL") 
     
    purrr::map(c("trt", "grade"), ~tbl_summary(trial, by = .x)) 
  • Updated tbl_uvregression() to allow flexible tidyselect inputs and improved error messaging for arguments x and y (#249)

  • After the input updates in #250, the exclude= argument appearing in add_p(), tbl_regression(), tbl_uvregression(), as_gt(), as_kable(), and as_tibble() was redundant. The exclude= argument is now deprecated. Use include= instead, with tidyselect syntax. (#331)

  • Functions all_categorical(), all_dichotomous(), and all_continuous() may now be used in tbl_summary() argument type= (#256)

User-facing improvements

  • New pattern= argument in inline_text.tbl_summary(). Previously, we could only grab the entire cell from a tbl_summary() with inline_text(), and now we can get any single statistic reported (#254)

  • Improved messaging for users who use knitr::kable() to print gtsummary tables, and users who have not yet installed the {gt} package (#347)

  • New function combine_terms() allows users to combine multiple independent variables in a regression model into a single line after tbl_regression(). The single line does not report regression coefficients, rather a single p-value from the anova() function. (#310)

  • In the regression modeling functions tbl_regression() and tbl_uvregression(), the users are presented an informative error message when the tidier fails (e.g. broom::tidy()) alerting them to the location of the error so they may address the issue (#337, #338)

  • For each release of gtsummary, we now can make reference to the version of gt our release coincides with. The commit SHA for gt is now saved in an object called gt_sha, and the version of gt can be installed with remotes::install_github("rstudio/gt", ref = gt_sha) (#329)

  • Created "style" family of functions

  • Improved error messaging in tidyselect_to_list() (#300)

Other features and fixes

  • Updated class detection to use inherits(), and added secondary class of "gtsummary" to all objects. This allows users to create their own cobbled/custom gtsummary objects while utilizing the gtsummary print functions (#249)

  • tbl_summary() will now summarize columns of class difftime (#343)

  • Infrastructure update to the way styling/formatting functions are returned. Styling functions are now returned as a column in the .$table_header tibble. The update simplifies handling of these styling functions in tbl_merge() and tbl_stack(). (#298, #299)

  • Bug fix for tbl_summary() when variables were all NA (#344)

  • The data summary function add_p() now uses probabilities rather than counts to calculate expected cell counts to avoid an error when working with large data sets. (#341)

  • Cubic spline terms are now accurately matched to a variable name/term (#312)

  • Bug fix when non-standard evaluation arguments were passed in method.args= argument of tbl_uvregression() (#322)

  • Updates after the gt package deprecated gt::cells_data() in favor of gt::cells_body(). Check added to as_gt() ensuring a version of gt with gt::cells_body() in its NAMESPACE

  • Lowered minimum required version of R to v3.4 (#356)

  • Removed {broom.mixed} dependency as the {broom} package contained all necessary tidiers (#354)

gtsummary 1.2.4 (2019-12-17)

17 Dec 15:49
f8e5dc3
Compare
Choose a tag to compare
  • Bug fix in as_kable() where column header did not match statistics presented when certain levels of the by= variable are entirely missing in tbl_summary() (#304)

  • Updated the trial example dataset "trt" variable to be "Drug A" and "Drug B" instead of "Placebo" and "Drug"

  • Improved messaging to users when an error or warning occurs while calculating a p-value in add_p(). Also, p-values are no longer omitted from output when a warning is encountered during their calculation (#283)

  • Added tidy_fun= argument to tbl_regression() and tbl_uvregression() allowing users to pass tidiers that are not in the {broom} and {broom.mixed} packages (#247)

gtsummary 1.2.3 (2019-11-12)

13 Nov 04:11
744e528
Compare
Choose a tag to compare
  • tbl_uvregression() now accepts an x= argument to build univariate regression models where the covariate x remains the same while models are built the with remaining variables as the outcome (#294)

  • Internal updates to the way {gt} is installed during CRAN checks.

  • Bug fix when stacking tbl_summary objects with calculated p-values.