Search code examples
rkable

Arrange kable interactive table by clicking on the column names


I'd like to be able to arrange a table by clicking the column name, like I can with View(.) in R

This is my code

library(kable)
library(kableExtra)

titanic %>% 
  kbl() %>%
  kable_styling(bootstrap_options = c("striped", "hover"),
                fixed_thead = T) %>% 
  scroll_box(width = "1000px", height = "1000px")

I click the column names now and it doesn't re order the columns and that's what I'd like to change


Solution

  • Adding this as an answer since I can't comment yet. I'd definetly also recommend using the datatable() package for making interactive tables.

    Also just to add, you might find this handy article on combining and using multiple packages to make interactive and beautiful tables.

    https://rfortherestofus.com/2019/11/how-to-make-beautiful-tables-in-r/