在Shiny中显示xtable

R_用户

我想用旋转的列标题以闪亮的方式显示数据表。我看到xtable包中的选项可以使用rotate.colheaders执行此操作。我无法使表格以闪亮的方式显示(没有所有打印格式),我得到的只是一个显示乳胶生成的文本字符串(请参见下文)。我怀疑这是一个很基本的观点,因为我知道我缺少一些东西-我只是不知道!

请参阅下面最小化的server.r代码示例和输出

server.r代码:

output$mytable <- renderUI({
    tab <- matrix(rep(1,6),nrow=3)
    rownames(tab) <- c('col1','col2','col3')
    M <- print(xtable(tab, rotate.colnames=TRUE))
})

在闪亮的应用程序中输出:

% latex table generated in R 3.1.1 by xtable 1.7-3 package % Wed Oct 22 13:31:00 2014 \begin{table}[ht] \centering \begin{tabular}{rrr} \hline & 1 & 2 \\ \hline col1 & 1.00 & 1.00 \\ col2 & 1.00 & 1.00 \\ col3 & 1.00 & 1.00 \\ \hline \end{tabular} \end{table}
克里斯托斯(Christos)

您应该在server.r中使用renderTable并在ui.r中使用tableOutput

在server.r中:

output$mytable <- renderTable({
    tab <- matrix(rep(1,6),nrow=3)
    colnames(tab) <- c('col1','col2')
    tab
    })

在ui.r中添加:

tags$head( tags$style( HTML('#mytable table {border-collapse:collapse; } 
                             #mytable table th { transform: rotate(-45deg)}'))),
column(6,tableOutput("mytable"))

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章