【发布时间】: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>
【问题讨论】:
-
使用 Shiny,您可以构建数据帧和其他 R 对象,这些对象将传递给负责呈现 HTML 和 JS(后者用于交互性)的 Shiny 函数(例如
renderDataTable,请参阅 shiny.rstudio.com/articles/datatables.html) )。我建议你阅读一些关于 Shiny 的教程。 -
感谢您的回答,我已经知道了。我的问题是如何使用 htmltools 处理它。