首页 > 解决方案 > 在 R 中粘贴 HTML 文本

问题描述

我正在尝试粘贴 HTML 值,如下所示。输出很好。但是我们也可以用另一种方式来做到这一点。我试过(参考 B 节)我将变量传递到 HTML

Section A
tags$div(style = "background-color:#cbe6ef;padding:5em",tags$table(tags$thead(tags$tr(tags$th("Number of Reviews","d")))))

<div style="background-color:#cbe6ef;padding:5em">
  <table>
    <thead>
      <tr>
        <th>
          Number of Reviews
          d
        </th>
      </tr>
    </thead>
  </table>
</div>

B节

as1 <- tags$table(tags$thead(tags$tr(tags$th("Number of Reviews","New"))))
tags$div(style = "background-color:#cbe6ef;padding:5em",HTML(paste("dis(\"",as1,"\")")))
<div style="background-color:#cbe6ef;padding:5em">dis(" <table>
  <thead>
    <tr>
      <th>
        Number of Reviews
        New
      </th>
    </tr>
  </thead>
</table> ")</div>

但是A部分的输出不一样。我们可以使输出类似于A部分吗?

标签: htmlrshiny

解决方案


推荐阅读