huxtable (version 0.3.0)

add_colnames: Add column or row names

Description

Add a first row of column names, or a first column of row names, to the huxtable.

Usage

add_colnames(ht, ...)

# S3 method for huxtable add_colnames(ht, rowname = NULL, ...)

add_rownames(ht, ...)

# S3 method for huxtable add_rownames(ht, colname = "rownames", preserve_rownames = TRUE, ...)

Arguments

ht

A huxtable.

...

Arguments passed to methods.

rowname

Optional row name for the new row of column names.

colname

Column name for the new column of row names.

preserve_rownames

Preserve existing row names.

Value

The modified object.

Details

Note that add_colnames will change the mode of all columns to character.

add_colnames preserves column names. add_rownames only preserves them if asked to.

Examples

Run this code
# NOT RUN {
ht <- huxtable(a = 1:5, b = 1:5)
add_rownames(ht)
add_colnames(ht)
add_rownames(add_colnames(ht)) # Out by 1
add_colnames(add_rownames(ht)) # Better
add_colnames(add_rownames(ht, '')) # Alternatively

# }

Run the code above in your browser using DataCamp Workspace