【问题标题】:Is it possible to have sortable (Interactive) table in rMarkdown?rMarkdown 中是否可以有可排序(交互式)表?
【发布时间】:2014-11-25 06:19:47
【问题描述】:

我正在使用 knitr 包中的kable() 在 html 文档上显示表格。是否有可能使其可排序?一些示例代码,

---
title: "Test"
output: html_document
---

```{r, echo=FALSE, comment=""}
kable(data.frame("a"=1:10,"b"=11:20),digits=2)
```

【问题讨论】:

标签: r knitr r-markdown


【解决方案1】:

DT (https://github.com/rstudio/DT) 是 JavaScript 库 DataTables 的 R 接口。您可以在 R Markdown 中使用它,例如

```{r}
DT::datatable(iris)
```

【讨论】:

  • 您能否提供一个示例来设置 DataTable 的选项?
  • 另外,是否可以在 R 对象的单列中包含多列?嵌套列表还是什么?在 kable 或数据表中。
  • @Yihui Xie 我们可以在循环后做同样的事情吗?喜欢使用需要数据帧或矩阵的数据表,但我有一个列表..
猜你喜欢
  • 2016-01-22
  • 2011-04-16
  • 2011-07-22
  • 1970-01-01
  • 2018-03-11
  • 2015-07-26
  • 2021-01-04
  • 1970-01-01
  • 2021-06-05
相关资源
最近更新 更多