Is it possible to have sortable (Interactive) table in rMarkdown?

浪子不回头ぞ 提交于 2019-12-03 11:06:00

问题


I am using kable() from knitr package to show a table on a html document. Is it possible to make it sortable? Some sample code,

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

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

回答1:


The package DT (https://github.com/rstudio/DT) is an R interface to the JavaScript library DataTables. You can use it in R Markdown, e.g.

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


来源:https://stackoverflow.com/questions/27120002/is-it-possible-to-have-sortable-interactive-table-in-rmarkdown

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!