【问题标题】:how to make table thru for loop in shiny/ htmltools?如何在闪亮/ htmltools 中使用 for 循环制作表格?
【发布时间】:2017-11-07 19:32:32
【问题描述】:

我正在尝试使用 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>

【问题讨论】:

标签: r shiny


【解决方案1】:
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.

## })

【讨论】:

  • 虽然此代码可能会回答问题,但提供有关此代码为何和/或如何回答问题的额外上下文可提高其长期价值。
猜你喜欢
  • 1970-01-01
  • 2018-02-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-22
  • 2018-04-05
  • 1970-01-01
  • 2019-01-10
相关资源
最近更新 更多