Learn R Programming

expss (version 0.8.7)

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

Description

This is method for rendering results of fre/cro/tables in Shiny/RMarkdown/Jupyter notebooks and etc. For detailed description of function and its arguments see htmlTable. You may be interested in expss_output_viewer() for automatical rendering tables in the RStudio viewer or expss_output_rnotebook() for rendering in the R notebooks. See expss.options. repr_html is method for rendering table in the Jupyter notebooks and knit_print is method for rendering table in the knitr HTML-documents. Jupyter notebooks and knitr documents are supported automatically but in the R notebooks it is needed to set output to notebook via expss_output_rnotebook().

Usage

# S3 method for etable
htmlTable(x, digits = get_expss_digits(),
  escape.html = FALSE, ..., row_groups = TRUE)

knit_print.etable(x, digits = get_expss_digits(), escape.html = FALSE, ...)

repr_html.etable(obj, digits = get_expss_digits(), escape.html = FALSE, ...)

repr_text.etable(obj, digits = get_expss_digits(), ...)

Arguments

x

a data object of class 'etable' - 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 setting option 'expss.digits' - for example, expss_digits(2). If it is NA than all numeric columns remain unrounded.

escape.html

logical: should HTML characters be escaped? Defaults to FALSE.

...

further parameters for htmlTable.

row_groups

logical Should we create row groups? TRUE by default.

obj

a data object of class 'etable' - result of fre/cro and etc.

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

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()
     
expss_output_default()   
 
# }

Run the code above in your browser using DataLab