Avinash
Avinash

Reputation: 2561

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

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)
```

Upvotes: 31

Views: 24938

Answers (1)

Yihui Xie
Yihui Xie

Reputation: 30114

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)
```

Upvotes: 65

Related Questions