Add_p() in tbl_summary

Good evening does someone know how to add p_values in this table for all the ages?
There is a general p_value but I would like adding a p_value to each age category.

Thank you again 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 e             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_p()%>%
  add_overall()
html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #atgcdohvld .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #atgcdohvld .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #atgcdohvld .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #atgcdohvld .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 4px; border-top-color: #FFFFFF; border-top-width: 0; } #atgcdohvld .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #atgcdohvld .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #atgcdohvld .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #atgcdohvld .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #atgcdohvld .gt_column_spanner_outer:first-child { padding-left: 0; } #atgcdohvld .gt_column_spanner_outer:last-child { padding-right: 0; } #atgcdohvld .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; overflow-x: hidden; display: inline-block; width: 100%; } #atgcdohvld .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #atgcdohvld .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #atgcdohvld .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #atgcdohvld .gt_from_md > :first-child { margin-top: 0; } #atgcdohvld .gt_from_md > :last-child { margin-bottom: 0; } #atgcdohvld .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #atgcdohvld .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #atgcdohvld .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #atgcdohvld .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #atgcdohvld .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #atgcdohvld .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #atgcdohvld .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #atgcdohvld .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #atgcdohvld .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #atgcdohvld .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #atgcdohvld .gt_sourcenote { font-size: 90%; padding: 4px; } #atgcdohvld .gt_left { text-align: left; } #atgcdohvld .gt_center { text-align: center; } #atgcdohvld .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #atgcdohvld .gt_font_normal { font-weight: normal; } #atgcdohvld .gt_font_bold { font-weight: bold; } #atgcdohvld .gt_font_italic { font-style: italic; } #atgcdohvld .gt_super { font-size: 65%; } #atgcdohvld .gt_footnote_marks { font-style: italic; font-size: 65%; }

Characteristic

Overall, N = 12

alive, N = 11

dead, N = 11

Discharged alive, N = 91

e, N = 11

p-value2

X1

6.50 (3.75, 9.25)

9.00 (9.00, 9.00)

5.00 (5.00, 5.00)

7.00 (4.00, 10.00)

2.00 (2.00, 2.00)

0.5

lockdown_date

0.9

After lockdown(March 17 to March 26, 2020)

11 (92%)

1 (100%)

1 (100%)

8 (89%)

1 (100%)

Before lockdown (February 28 to March 16, 2020

1 (8.3%)

0 (0%)

0 (0%)

1 (11%)

0 (0%)

Age_category

0.9

(50 to 59 years]

4 (33%)

0 (0%)

0 (0%)

3 (33%)

1 (100%)

(60 to 69 years]

3 (25%)

1 (100%)

0 (0%)

2 (22%)

0 (0%)

[18 to 40 years)

3 (25%)

0 (0%)

1 (100%)

2 (22%)

0 (0%)

Above 80 years

1 (8.3%)

0 (0%)

0 (0%)

1 (11%)

0 (0%)

Under 18 years

1 (8.3%)

0 (0%)

0 (0%)

1 (11%)

0 (0%)

SEX

0.9

F

7 (58%)

0 (0%)

1 (100%)

5 (56%)

1 (100%)

M

5 (42%)

1 (100%)

0 (0%)

4 (44%)

0 (0%)

1

Statistics presented: median (IQR); n (%)

2

Statistical tests performed: Kruskal-Wallis test; Fisher’s exact test

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.