--- title: "[R Markdown] DT::datatable tutorial" author: "by SK C&C 이다경 선임 -`r format(Sys.Date())`" output: rmdformats::readthedown: code_folding: show number_sections: TRUE --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo=TRUE, warning=FALSE, message=FALSE, results = 'asis') options(warn = F) library(DT) ``` # 기본 ```{r} datatable(iris) ```


# cation :: 제목 추가 ```{r} datatable(iris, caption = "IRIS DATA SET") ```


# rownames :: ROW INDEX 삭제 ```{r} datatable(iris, caption = "IRIS DATA SET", rownames = F) ```


# colnames :: Column 명 변경 ```{r} datatable(iris, caption = "IRIS DATA SET", rownames = F, colnames = c("Col1"="Sepal.Length")) ```


# filter ```{r} datatable(iris, caption = "IRIS DATA SET", rownames = F, colnames = c("Col1"="Sepal.Length"), filter = "bottom") ```


# width, height ```{r} datatable(iris, caption = "IRIS DATA SET", rownames = F, colnames = c("Col1"="Sepal.Length"), filter = "bottom", width = 500, height = 500) ```


# editable ```{r} datatable(iris, caption = "IRIS DATA SET", rownames = F, colnames = c("Col1"="Sepal.Length"), filter = "bottom", editable = T) ```


# extensions + options :: datatable 파일 저장하기 {.tabset} ## no scroll ```{r} datatable(dplyr::bind_cols(iris,iris), caption = "IRIS DATA SET", rownames = F, filter = "bottom", editable = T, extensions = "Buttons", options = list(dom ='Bfrtip', buttons =c(I('colvis'),'copy','csv', 'excel','print','pdf'), pageLength = 10)) ```


## scroll ```{r} datatable(dplyr::bind_cols(iris,iris), caption = "IRIS DATA SET", rownames = F, # colnames = c("Col1"="Sepal.Length"), filter = "bottom", editable = T, extensions = "Buttons", options = list(dom ='Bfrtip', buttons =c(I('colvis'),'copy','csv', 'excel','print','pdf'), pageLength = 10, scrollX = T)) ```


# class {.tabset} ```{r} class <- c("display","cell-border","compact","hover","nowrap","order-column","row-border","stripe") for(i in class){ cat("\n\n##",i,"\n\n") print(htmltools::tagList(datatable(dplyr::bind_cols(iris,iris), caption = "IRIS DATA SET", rownames = F, filter = "bottom", editable = T, extensions = "Buttons", width = 800, options = list(dom ='Bfrtip', buttons =c(I('colvis'),'copy','csv', 'excel','print','pdf'), pageLength = 10, scrollX = T), class = i))) cat("\n\n


\n\n") } ```