crosstab output getting displayed in viewer pane only and not in Shiny app

前端 未结 1 1294
清歌不尽
清歌不尽 2021-01-23 10:19

I am generating a cross table output (contingency table). My requirement is to have column percentages along with row and column totals. I found this package \"sjPlot\"<

1条回答
  •  深忆病人
    2021-01-23 11:14

    sjt.xtabinvisibly returns a list that contains the html and css used to generate the table that you see in the viewer.

    You can use htmlOutput on the ui side and renderUI on the server side to display it.

    In your ui.R, you can use:

    htmlOutput("crosstab2")
    

    In your server.R:

      output$crosstab2 <- renderUI({
        custom_table <- sjt.xtab(mtcars$mpg, mtcars$cyl,variableLabels = c("mpg","cyl"),showColPerc = T,
                                 showSummary = F,showNA=F,highlightTotal = T,tdcol.col = "#f90477", highlightColor ="#3aaee0",
                                 CSS = list(css.table = "border: 1px solid;",
                                            css.tdata = "border: 1px solid;"))
        HTML(custom_table$knitr)
      })
    

    Here's (part of) my sessionInfo()

    R version 3.1.2 (2014-10-31)
    Platform: x86_64-apple-darwin13.4.0 (64-bit)
    
    locale:
    [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
    [1] sjPlot_1.9.2 shiny_0.13.1
    

    I suspect we don't have the same version of sjPlot as the arguments of the sjt.xtab you use in your example have changed names.

    0 讨论(0)
提交回复
热议问题