1 기본

datatable(iris) 



2 cation :: 제목 추가

datatable(iris,
          caption = "IRIS DATA SET") 



3 rownames :: ROW INDEX 삭제

datatable(iris,
          caption = "IRIS DATA SET",
          rownames = F) 



4 colnames :: Column 명 변경

datatable(iris,
          caption = "IRIS DATA SET",
          rownames = F,
          colnames = c("Col1"="Sepal.Length")) 



5 filter

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



6 width, height

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



7 editable

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



8 extensions + options :: datatable 파일 저장하기

8.1 no scroll

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



8.2 scroll

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



9 class

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<br><hr><br>\n\n")
  
}

9.1 display




9.2 cell-border




9.3 compact




9.4 hover




9.5 nowrap




9.6 order-column




9.7 row-border




9.8 stripe