【问题标题】:How to include Data Table from R package (DT) into another HTML file如何将 R 包 (DT) 中的数据表包含到另一个 HTML 文件中
【发布时间】:2018-01-18 15:06:50
【问题描述】:

我使用R包DT生成了一个数据表如下,

library(DT)
load.this <- "DT"
data <- as.matrix(read.table("/path/to/file/name.txt", header = TRUE, fill = TRUE))
table <- datatable(data, filter = 'top',options = list(columnDefs = list(list(targets = c(1, 3), searchable = FALSE)),pageLength = 10))    

我的目标是将上表嵌入到另一个 HTML 文件中,但即使在尝试使用 manual 中的 escape 参数进行几次尝试后,我也不知道该怎么做。

例如,如何将表格包含在 HTML 标记中,

       <html>
       <body>
<h1> Table from DT package</h1>

    Table comes here

      </body>
      </html> 

【问题讨论】:

  • 搜索knitr,如果你使用R studio,你可以试试File &gt; new file &gt; RMarkdown...并从那里获取

标签: javascript html r package dt


【解决方案1】:

您好,您可以将其保存为htmlwidget

library(DT)

iris_DT <- datatable(iris)

saveWidget(iris_DT, "iris_DT.html", selfcontained = TRUE, libdir = NULL,
           background = "white", knitrOptions = list())

然后将其包含在邮件 html 文档中的 iframe 中

【讨论】:

  • 感谢您的宝贵时间,这正是我要找的@s.brunel
猜你喜欢
  • 2011-11-24
  • 2017-04-06
  • 2018-03-02
  • 2013-06-25
  • 1970-01-01
  • 1970-01-01
  • 2013-06-13
  • 2012-02-17
相关资源
最近更新 更多