Learn R Programming

huxtable (version 4.0.0)

huxtable: Create a huxtable

Description

huxtable, or hux, creates a huxtable object.

Usage

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, ...)

# S3 method for default as_huxtable(x, add_colnames = getOption("huxtable.add_colnames", FALSE), add_rownames = FALSE, autoformat = getOption("huxtable.autoformat", TRUE), ...)

is_huxtable(x)

is_hux(x)

Arguments

...

For huxtable, named list of values as in data.frame(). For as_huxtable, extra arguments.

add_colnames

If TRUE, add a first row of column names to the huxtable.

add_rownames

If TRUE, add a first column of row names, named 'rownames', to the huxtable.

autoformat

If TRUE, automatically format columns by type. See below.

x

An object to convert to a huxtable.

Value

An object of class huxtable.

Details

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.

Examples

Run this code
# NOT RUN {
ht <- huxtable(column1 = 1:5, column2 = letters[1:5])
dfr <- data.frame(a = 1:5, b = letters[1:5], stringsAsFactors = FALSE)
as_huxtable(dfr)

# }

Run the code above in your browser using DataLab