Last data update: 2014.03.03

R: Helper functions for using DT in Shiny
dataTableOutputR Documentation

Helper functions for using DT in Shiny

Description

These two functions are like most fooOutput() and renderFoo() functions in the shiny package. The former is used to create a container for table, and the latter is used in the server logic to render the table.

Usage

dataTableOutput(outputId, width = "100%", height = "auto")

renderDataTable(expr, server = TRUE, env = parent.frame(), quoted = FALSE, ...)

Arguments

outputId

output variable to read the table from

width

the width of the table container

height

the height of the table container

expr

an expression to create a table widget (normally via datatable()), or a data object to be passed to datatable() to create a table widget

server

whether to use server-side processing. If TRUE, then the data is kept on the server and the browser requests a page at a time; if FALSE, then the entire data frame is sent to the browser at once. Highly recommended for medium to large data frames, which can cause browsers to slow down or crash.

env

The environment in which to evaluate expr.

quoted

Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.

...

ignored when expr returns a table widget, and passed as additional arguments to datatable() when expr returns a data object

References

http://rstudio.github.io/DT/shiny.html

Examples

if (interactive()) {
  library(shiny)
  shinyApp(
    ui = fluidPage(fluidRow(column(12, DT::dataTableOutput('tbl')))),
    server = function(input, output) {
      output$tbl = DT::renderDataTable(
        iris, options = list(lengthChange = FALSE)
      )
    }
  )
}

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(DT)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DT/dataTableOutput.Rd_%03d_medium.png", width=480, height=480)
> ### Name: dataTableOutput
> ### Title: Helper functions for using DT in Shiny
> ### Aliases: dataTableOutput renderDataTable
> 
> ### ** Examples
> 
> #if (interactive()) {
>   library(shiny)

Attaching package: 'shiny'

The following objects are masked from 'package:DT':

    dataTableOutput, renderDataTable

>   shinyApp(
+     ui = fluidPage(fluidRow(column(12, DT::dataTableOutput('tbl')))),
+     server = function(input, output) {
+       output$tbl = DT::renderDataTable(
+         iris, options = list(lengthChange = FALSE)
+       )
+     }
+   )

Listening on http://127.0.0.1:4318