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

我的未来我决定 提交于 2019-12-02 07:17:22

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!