Skip to content

Statistical tests not displayed in HTML output with pfootnote = TRUE in Shiny #371

Description

@PietropaoliLab

Hello,
I’m experiencing an issue with including statistical tests in the HTML output of a Shiny app using the arsenal package. Despite setting pfootnote = TRUE in the summary(tableby(...)) function, the statistical tests do not appear in the generated HTML output.

Here is the code I am using:

library(shiny)
library(arsenal)
data(mockstudy)

shinyApp(
  ui = fluidPage(tableOutput("table")),
  server = function(input, output) {
    output$table <- renderTable({
      as.data.frame(summary(tableby(sex ~ age, data = mockstudy), text = "html", pfootnote = TRUE))
    }, sanitize.text.function = function(x) x)
  }
)

The HTML output generated by this code is as follows:

<table>
 <thead>
  <tr>
   <th style="text-align:left;">  </th>
   <th style="text-align:center;"> Female (N=6) </th>
   <th style="text-align:center;"> Male (N=13) </th>
   <th style="text-align:center;"> Total (N=19) </th>
   <th style="text-align:right;"> p value </th>
  </tr>
 </thead>
<tbody>
  <tr>
   <td style="text-align:left;"> <strong>DM</strong> </td>
   <td style="text-align:center;">  </td>
   <td style="text-align:center;">  </td>
   <td style="text-align:center;">  </td>
   <td style="text-align:right;"> 0.405<sup>1</sup> </td>
  </tr>
  <tr>
   <td style="text-align:left;"> &nbsp;&nbsp;&nbsp;No </td>
   <td style="text-align:center;"> 4 (66.7%) </td>
   <td style="text-align:center;"> 6 (46.2%) </td>
   <td style="text-align:center;"> 10 (52.6%) </td>
   <td style="text-align:right;">  </td>
  </tr>
  <tr>
   <td style="text-align:left;"> &nbsp;&nbsp;&nbsp;Yes </td>
   <td style="text-align:center;"> 2 (33.3%) </td>
   <td style="text-align:center;"> 7 (53.8%) </td>
   <td style="text-align:center;"> 9 (47.4%) </td>
   <td style="text-align:right;">  </td>
  </tr>
  <tr>
   <td style="text-align:left;"> <strong>age</strong> </td>
   <td style="text-align:center;">  </td>
   <td style="text-align:center;">  </td>
   <td style="text-align:center;">  </td>
   <td style="text-align:right;"> 0.216<sup>2</sup> </td>
  </tr>
  <tr>
   <td style="text-align:left;"> &nbsp;&nbsp;&nbsp;Mean (SD) </td>
   <td style="text-align:center;"> 70.500 (8.503) </td>
   <td style="text-align:center;"> 64.308 (10.250) </td>
   <td style="text-align:center;"> 66.263 (9.943) </td>
   <td style="text-align:right;">  </td>
  </tr>
  <tr>
   <td style="text-align:left;"> &nbsp;&nbsp;&nbsp;Range </td>
   <td style="text-align:center;"> 59.000 - 83.000 </td>
   <td style="text-align:center;"> 45.000 - 86.000 </td>
   <td style="text-align:center;"> 45.000 - 86.000 </td>
   <td style="text-align:right;">  </td>
  </tr>
</tbody>
</table>
1. Pearson's Chi-squared test
2. Linear Model ANOVA

As shown, the statistical tests (footnotes) are included at the bottom, but they do not appear as expected in the rendered HTML output. It seems that the pfootnote argument is not being applied correctly.

Could you please assist in diagnosing this issue or suggest a workaround to ensure the statistical tests are displayed properly in the HTML output?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions