Missed Labels on summary table with qwraps2

33 Views Asked by At

I am using R markdown to create summary statistics table with qwraps2. I am not able to get the desired output and I can spot where is my mistake. I have practiced on mtcars2 and everything was alright. I want to get a proper table with all the labels. And also, why the last cell has 2 numbers (highlighted)?

Sample Data
DELTA_LYSHOLM   DELTA_TEGNER    DELTA_IKDC
28  0   0
0   0   0
0   4.6 
0   4.2 
0   3.7 
35  0   0
0   0   31.04
0   0   42
0   0   0
0   0   0
48  6   81
46  7   88
10.4    0.9 0
0   0   0
19  0   0
0   0   0
0   0   0
0   0   0
0   0   19.2
83.3    0   78
30.67   0   0
Library(tidyverse)
Library(qwraps2)
Library(readxl)
Summary_Descriptive <-
  list("Delta Lysholm Scores" =
       list("min"       = ~ min(DELTA_LYSHOLM),
            "max"       = ~ max(DELTA_LYSHOLM),
            "mean (sd)" = ~ qwraps2::mean_sd(DELTA_LYSHOLM, na_rm = TRUE, denote_sd = "paren")),
       "Delta Tegner scores" =
       list("min"       = ~ min(DELTA_TEGNER),
            "max"       = ~ max(DELTA_TEGNER),
            "mean (sd)" = ~ qwraps2::mean_sd(DELTA_TEGNER, na_rm = TRUE, denote_sd = "paren")),
       "Delta IKDC Scores" =
       list("min"       = ~ min(DELTA_IKDC),
            "max"       = ~ max(DELTA_IKDC),
            "mean (sd)" = ~ qwraps2::mean_sd(DELTA_IKDC, na_rm = TRUE, denote_sd = "paren"))
       )

Final_Descriptive <- summary_table(ACLR_CHONDRAL, Summary_Descriptive)
Final_Descriptive

Then this what I am getting.

ACL  (N = 21)
    
min 0
max 83.3
mean..sd.   14.30 (22.89)
min.1   0
max.1   7
mean..sd..1 1.26 (2.29)
min.2   NA
max.2   NA
mean..sd..2 18; 18.85 (31.71)

I could not find an answer to try

1

There are 1 best solutions below

1
TarJae On

We have to add this line to your code:

options(qwraps2_markup = 'markdown') # default is latex

library(qwraps2)
options(qwraps2_markup = 'markdown') # default is latex

ACL_data <- structure(list(DELTA_LYSHOLM = c(28, 0, 0, 0, 0, 35, 0, 0, 0, 
0, 48, 46, 10.4, 0, 19, 0, 0, 0, 0, 83.3, 30.67), DELTA_TEGNER = c(0, 
0, 4.6, 4.2, 3.7, 0, 0, 0, 0, 0, 6, 7, 0.9, 0, 0, 0, 0, 0, 0, 
0, 0), DELTA_IKDC = c(0, 0, 0, 0, 0, 0, 31.04, 42, 0, 0, 81, 
88, 0, 0, 0, 0, 0, 0, 19.2, 78, 0)), class = "data.frame", row.names = c(NA, 
-21L))

Summary_Descriptive <-
  list("Delta Lysholm Scores" =
         list("min"       = ~ min(DELTA_LYSHOLM),
              "max"       = ~ max(DELTA_LYSHOLM),
              "mean (sd)" = ~ qwraps2::mean_sd(DELTA_LYSHOLM, na_rm = TRUE, denote_sd = "paren")),
       "Delta Tegner scores" =
         list("min"       = ~ min(DELTA_TEGNER),
              "max"       = ~ max(DELTA_TEGNER),
              "mean (sd)" = ~ qwraps2::mean_sd(DELTA_TEGNER, na_rm = TRUE, denote_sd = "paren")),
       "Delta IKDC Scores" =
         list("min"       = ~ min(DELTA_IKDC),
              "max"       = ~ max(DELTA_IKDC),
              "mean (sd)" = ~ qwraps2::mean_sd(DELTA_IKDC, na_rm = TRUE, denote_sd = "paren"))
  )

summary_table(ACL_data, Summary_Descriptive)
|                         |ACL_data (N = 21) |
|:------------------------|:-----------------|
|**Delta Lysholm Scores** |&nbsp;&nbsp;      |
|&nbsp;&nbsp; min         |0                 |
|&nbsp;&nbsp; max         |83.3              |
|&nbsp;&nbsp; mean (sd)   |14.30 (22.89)     |
|**Delta Tegner scores**  |&nbsp;&nbsp;      |
|&nbsp;&nbsp; min         |0                 |
|&nbsp;&nbsp; max         |7                 |
|&nbsp;&nbsp; mean (sd)   |1.26 (2.29)       |
|**Delta IKDC Scores**    |&nbsp;&nbsp;      |
|&nbsp;&nbsp; min         |0                 |
|&nbsp;&nbsp; max         |88                |
|&nbsp;&nbsp; mean (sd)   |16.15 (30.00)     |