Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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) ``` 
like image 213
Avinash Avatar asked Nov 25 '14 06:11

Avinash


People also ask

How do I embed a table in rmarkdown?

Upon installing, inserttable registers a new RStudio Addin (Insert Table) that can be used to easily insert a table in a Rmd document. To use it, open a Rmd or R document and select “Addins –> Insert Table”.

What is Knitr in rmarkdown?

knitr is an engine for dynamic report generation with R. It is a package in the programming language R that enables integration of R code into LaTeX, LyX, HTML, Markdown, AsciiDoc, and reStructuredText documents. The purpose of knitr is to allow reproducible research in R through the means of literate programming.

Why would you use rmarkdown?

rmarkdown provides an environment where you can write your complete analysis, and marries your text, and code together into a rich document. You write your code as code chunks, put your text around that, and then hey presto, you have a document you can reproduce.


1 Answers

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) ``` 
like image 65
Yihui Xie Avatar answered Sep 19 '22 06:09

Yihui Xie