as_huxtable or as_hux converts an object to a huxtable. Conversion methods exist for data frames and tibbles, tables, ftables, matrices and (most) vectors.
as_huxtable(x,...)as_hux(x,...)## Default S3 method:as_huxtable( x, add_colnames = getOption("huxtable.add_colnames",TRUE), add_rownames =FALSE, autoformat = getOption("huxtable.autoformat",TRUE),...)## S3 method for class 'grouped_df'as_huxtable(x,..., groups_to_headers =FALSE)is_huxtable(x)is_hux(x)
Arguments
x: Object to convert.
...: Arguments passed on to huxtable().
add_colnames: If TRUE, add a first row of column names to the huxtable.
add_rownames: If TRUE or a character string, add a first column of row names to the huxtable. The string gives the name for the new column (or "rownames" for TRUE).
autoformat: If TRUE, automatically format columns by type. See below.
groups_to_headers: Logical. Convert groups to header rows?
Returns
An object of class "huxtable".
Details
is_hux[table] tests if an object is a huxtable.
For table objects, add_colnames and add_rownames are TRUE by default. For matrix objects, they are FALSE. Other classes use options("huxtable.add_colnames"), which is TRUE by default; add_rownames
is FALSE.
For dplyr::grouped_df() objects, groups will be converted to header rows if groups_to_headers is TRUE.