as.datatable_widget: Create an HTML table widget for usage with Shiny

Description Usage Arguments Value See Also Examples

Description

This is method for rendering results of tables/fre/cro in Shiny. DT package should be installed for this feature (install.packages('DT')). For detailed description of function and its arguments see datatable.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
as.datatable_widget(data, ...)

## S3 method for class 'etable'
as.datatable_widget(data, repeat_row_labels = FALSE,
  show_row_numbers = FALSE, digits = get_expss_digits(), ...)

## S3 method for class 'with_caption'
as.datatable_widget(data,
  repeat_row_labels = FALSE, show_row_numbers = FALSE,
  digits = get_expss_digits(), ...)

Arguments

data

a data object (result of tables/fre/cro).

...

further parameters for datatable

repeat_row_labels

logical Should we repeat duplicated row labels in the every row? Default is FALSE.

show_row_numbers

logical Default is FALSE.

digits

integer By default, all numeric columns are rounded to one digit after decimal separator. Also you can set this argument by option 'expss.digits' - for example, expss_digits(2). If it is NA than all numeric columns remain unrounded.

Value

Object of class datatable

See Also

htmlTable for knitting

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
## Not run:  

data(mtcars)
mtcars = apply_labels(mtcars,
                      mpg = "Miles/(US) gallon",
                      cyl = "Number of cylinders",
                      disp = "Displacement (cu.in.)",
                      hp = "Gross horsepower",
                      drat = "Rear axle ratio",
                      wt = "Weight (1000 lbs)",
                      qsec = "1/4 mile time",
                      vs = "Engine",
                      vs = c("V-engine" = 0,
                             "Straight engine" = 1),
                      am = "Transmission",
                      am = c("Automatic" = 0,
                             "Manual"=1),
                      gear = "Number of forward gears",
                      carb = "Number of carburetors"
)

mtcars_table = mtcars %>% 
                 tab_cols(total(), am %nest% vs) %>% 
                 tab_cells(mpg, hp) %>% 
                 tab_stat_mean() %>% 
                 tab_cells(cyl) %>% 
                 tab_stat_cpct() %>% 
                 tab_pivot() %>% 
                 set_caption("Table 1. Some variables from mtcars dataset.")

library(shiny)
shinyApp(
    ui = fluidPage(fluidRow(column(12, DT::dataTableOutput('tbl')))),
    server = function(input, output) {
        output$tbl = DT::renderDataTable(
            as.datatable_widget(mtcars_table)
        )
    }
)

## End(Not run)

gdemin/expss documentation built on May 16, 2019, 11:14 p.m.