Problem with add_overall function

Good evening,

Can someone help me with the add_overall function on gtsummary package?.

I am trying to create a table but there is a missing value on the status row of my table and the overall column gives me this error. Does someone know what can I do in order to create this table?.

Thank you very much for your help.


library(reprex)
#> Warning: package 'reprex' was built under R version 3.6.3
library(readr)
library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 3.6.3
#> Warning: package 'ggplot2' was built under R version 3.6.3
#> Warning: package 'tibble' was built under R version 3.6.3
#> Warning: package 'tidyr' was built under R version 3.6.3
#> Warning: package 'dplyr' was built under R version 3.6.3
#> Warning: package 'forcats' was built under R version 3.6.3
library(dplyr)
library(tibble)
library(psych)
#> Warning: package 'psych' was built under R version 3.6.3
#> 
#> Attaching package: 'psych'
#> The following objects are masked from 'package:ggplot2':
#> 
#>     %+%, alpha
library(flextable)
#> Warning: package 'flextable' was built under R version 3.6.3
#> 
#> Attaching package: 'flextable'
#> The following object is masked from 'package:purrr':
#> 
#>     compose
library(Gmisc)
#> Warning: package 'Gmisc' was built under R version 3.6.3
#> Loading required package: Rcpp
#> Loading required package: htmlTable
#> Warning: package 'htmlTable' was built under R version 3.6.3
library(Hmisc)
#> Warning: package 'Hmisc' was built under R version 3.6.3
#> Loading required package: lattice
#> Loading required package: survival
#> Loading required package: Formula
#> 
#> Attaching package: 'Hmisc'
#> The following object is masked from 'package:psych':
#> 
#>     describe
#> The following objects are masked from 'package:dplyr':
#> 
#>     src, summarize
#> The following objects are masked from 'package:base':
#> 
#>     format.pval, units
library(kableExtra)
#> Warning: package 'kableExtra' was built under R version 3.6.3
#> 
#> Attaching package: 'kableExtra'
#> The following objects are masked from 'package:flextable':
#> 
#>     as_image, footnote
#> The following object is masked from 'package:dplyr':
#> 
#>     group_rows
library(knitr)
#> Warning: package 'knitr' was built under R version 3.6.3
library(prettydoc)
#> Warning: package 'prettydoc' was built under R version 3.6.3
library(gtsummary)
#> Warning: package 'gtsummary' was built under R version 3.6.3
#> 
#> Attaching package: 'gtsummary'
#> The following object is masked from 'package:flextable':
#> 
#>     as_flextable
library(eeptools)
#> Warning: package 'eeptools' was built under R version 3.6.3
library(rstudioapi)
#> Warning: package 'rstudioapi' was built under R version 3.6.3
library(htmlTable)
de <- read_csv("C:/Users/juanp/Desktop/de.csv")
#> Warning: Missing column names filled in: 'X1' [1]
#> Parsed with column specification:
#> cols(
#>   X1 = col_double(),
#>   status = col_character(),
#>   lockdown_date = col_character(),
#>   Age_category = col_character(),
#>   SEX = col_character()
#> )

de
#> # A tibble: 12 x 5
#>       X1 status        lockdown_date                        Age_category   SEX  
#>    <dbl> <chr>         <chr>                                <chr>          <chr>
#>  1     1 Discharged a~ Before lockdown (February 28 to Mar~ (50 to 59 yea~ M    
#>  2     2 <NA>          After lockdown(March 17 to March 26~ (50 to 59 yea~ F    
#>  3     3 Discharged a~ After lockdown(March 17 to March 26~ [18 to 40 yea~ M    
#>  4     4 Discharged a~ After lockdown(March 17 to March 26~ Above 80 years F    
#>  5     5 dead          After lockdown(March 17 to March 26~ [18 to 40 yea~ F    
#>  6     6 Discharged a~ After lockdown(March 17 to March 26~ (50 to 59 yea~ F    
#>  7     7 Discharged a~ After lockdown(March 17 to March 26~ [18 to 40 yea~ F    
#>  8     8 Discharged a~ After lockdown(March 17 to March 26~ (50 to 59 yea~ F    
#>  9     9 alive         After lockdown(March 17 to March 26~ (60 to 69 yea~ M    
#> 10    10 Discharged a~ After lockdown(March 17 to March 26~ Under 18 years M    
#> 11    11 Discharged a~ After lockdown(March 17 to March 26~ (60 to 69 yea~ M    
#> 12    12 Discharged a~ After lockdown(March 17 to March 26~ (60 to 69 yea~ F

tbl_summary(de,
            by=status)%>%
  add_overall()
#> 1 observations missing `status` have been removed. To include these observations, use `forcats::fct_explicit_na()` on `status` column before passing to `tbl_summary()`.
#> Error in (function (data, by = NULL, label = NULL, statistic = NULL, digits = NULL, : unused arguments (i = "SEX", lbls = list(NULL, NULL, NULL, NULL, NULL))

Created on 2020-05-17 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.