Learn R Programming

expss (version 0.7.1)

htmlTable.etable: Outputting HTML tables in RStudio viewer/R Notebooks

Description

This is method for rendering results of fre/cro/tables in Shiny/RMarkdown and etc. For detailed description of function and its arguments see htmlTable. You may be interested in options(expss.output = "viewer") for automatical rendering tables in the RStudio viewer or options(expss.output = "rnotebook") for rendering in the R notebooks. See expss.options.

Usage

# S3 method for etable
htmlTable(x, digits = getOption("expss.digits"), ...)

knit_print.etable(x, digits = getOption("expss.digits"), ...)

Arguments

x

a data object (result of fre/cro and etc)

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, option(expss.digits = 2). If it is NA than all numeric columns remain unrounded.

...

further parameters for htmlTable.

Value

Returns a string of class htmlTable

Examples

Run this code
# 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"
)

options(expss.output = "viewer")
mtcars %>% 
     tab_cols(total(), am %nest% vs) %>% 
     tab_cells(mpg, hp) %>% 
     tab_stat_mean() %>% 
     tab_cells(cyl) %>% 
     tab_stat_cpct() %>% 
     tab_pivot()
     
options(expss.output = NA)   
 
# }

Run the code above in your browser using DataLab