| huxtable {huxtable} | R Documentation |
huxtable, or hux, creates a huxtable object.
huxtable(..., add_colnames = getOption("huxtable.add_colnames", FALSE),
add_rownames = FALSE, autoformat = getOption("huxtable.autoformat", TRUE))
hux(..., add_colnames = getOption("huxtable.add_colnames", FALSE),
add_rownames = FALSE, autoformat = getOption("huxtable.autoformat", TRUE))
as_huxtable(x, ...)
as_hux(x, ...)
## Default S3 method:
as_huxtable(x,
add_colnames = getOption("huxtable.add_colnames", FALSE),
add_rownames = FALSE, autoformat = getOption("huxtable.autoformat", TRUE),
...)
is_huxtable(x)
is_hux(x)
... |
For |
add_colnames |
If |
add_rownames |
If |
autoformat |
If |
x |
An object to convert to a huxtable. |
If you use add_colnames or add_rownames, be aware that these will shift your rows and columns
along by one: your old row/column 1 will now be row/column 2, etc.
add_colnames currently defaults to FALSE, but this will change in future. You can set
the default globally by setting options("huxtable.add_colnames") to TRUE or FALSE.
as_huxtable and as_hux convert an object to a huxtable.
Conversion methods exist for data frames, tables, ftables, matrices and (most) vectors.
An object of class huxtable.
If autoformat is TRUE, then columns will have number_format() and align() properties
set automatically, as follows:
Integer columns will have number_format set to 0.
Other numeric columns will have number_format set to "%.3g".
All other columns will have number_format set to NA (no formatting).
Integer, Date and date-time (i.e. POSIXct and POSIXlt) columns will be right-aligned.
Other numeric columns will be aligned on options("OutDec"), usually ".".
Other columns will be left aligned.
You can change these defaults by editing options("huxtable.autoformat_number_format") and
options("huxtable.autoformat_align"). See huxtable-package for more details.
Automatic alignment also applies to column headers if add_colnames is TRUE; headers of
columns aligned on a decimal point will be right-aligned. Automatic number formatting does not
apply to column headers.
ht <- huxtable(column1 = 1:5, column2 = letters[1:5]) dfr <- data.frame(a = 1:5, b = letters[1:5], stringsAsFactors = FALSE) as_huxtable(dfr)