项目作者: vadimus202

项目描述 :
A Friendly Datatable
高级语言: R
项目地址: git://github.com/vadimus202/datatableEZ.git
创建时间: 2017-04-15T23:17:29Z
项目社区:https://github.com/vadimus202/datatableEZ

开源协议:Other

下载


Travis-CI Build Status AppVeyor Build Status

A Friendly Datatable

The DT package is a wrapper of the JavaScript library ‘DataTables’, and is a powerful way of rendering HTML tables from R dataframes using JavaScript, usually via Markdown or Shiny. This package is mostly a wrapper around DT::datatable() with more convenient defaults and simplified syntax.

The most common elements of the options() list argument are moved to direct arguments of the datatable_EZ() function. This avoids the need to include a long list of options and provides additional documentation and examples of their usage.

Read the Interactive Data Tables vignette for some examples.

Installation

To install the development version:

  1. devtools::install_github(repo = "datatableEZ",
  2. username = "vadimus202",
  3. build_vignettes = TRUE)

Common Usage

  1. library(datatableEZ)

Original datatable

  • Includes row numbers by default
  • Less compact
  • Options are not well documented
  1. datatable(iris)

Easy Datatable

  • By default:
    • More compact
    • No row numbers
    • Search highlights
  • Direct access to options through named arguments:
    • DOM elements
    • Column definitions (width, alignment, etc.)
    • Rows sorting
    • Page length
  1. datatable_EZ(
  2. iris,
  3. dom="t",
  4. columnDefs = list(list(width = '50px', targets = c(1, 3))),
  5. order = list(list(0, 'desc'), list(1, 'asc'))
  6. )

Font Control

the DT package doesn’t set the default font family. So the browser will use its default font to display the datatable. That’s why you find the font displays differently in different browsers.

  1. datatable_EZ(iris, font_family = "Courier New", font_size = 9)

Specify Column Widths in Pixels

  1. datatable_EZ(
  2. iris,
  3. col_widths = c(50, 50, 300, 50, 300)
  4. )

Pagination

  • Number of rows per page
  • Page length drop-down options
  1. datatable_EZ(iris, pageLength = 3, lengthMenu = c(3,5,10))

Static Version

Disables sorting and searching by the user.

  1. datatable_EZ(iris, ordering = FALSE, dom = "t")

Conditional Databars

A simple way to add conditional formatting databars to one or more columns.

  1. iris %>%
  2. datatable_EZ() %>%
  3. format_databars(~Sepal.Length + Sepal.Width + Petal.Length)