如何通过shiny / htmltools创建循环表?

时间:2017-11-07 09:16:40

标签: r shiny

我尝试使用for循环创建/打印/显示Shiny R表,但是我的for循环不会返回HTML。你能帮助我找出我的for循环有什么问题吗?提前谢谢!

div(style="font-size: 9pt; font-family:calibri;",
    tags$table(
      tags$caption("Market Split"),
      tags$tr(
        tags$th(names(dpe1)[1]),
        tags$th(names(dpe1)[2])
      ),
      for (i in 1:nrow(dpe1)){
        tags$tr(
          tags$td(dpe1[i,1]),
          tags$td(dpe1[i,2])
        )}
    ))

结果:

<div style="font-size: 9pt; font-family:calibri;">
  <table>
    <caption>Market Split</caption>
    <tr>
      <th>Planning.Area</th>
      <th>Reporting.Country</th>
    </tr>
  </table>
</div>

1 个答案:

答案 0 :(得分:0)

You can use DT::renderDataTable option--

##output$contents1 <- DT::renderDataTable({
##Create Dataframes using loop

##Show table in main panel using datatable(Dataframe)

##return(Dataframe)##This dataframe you can use in your script for further 
use.

## })