add_colnames: Add column or row names

Description Usage Arguments Details Value Examples

Description

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

Usage

1
2
3
4
5
6
7
8
9
add_colnames(ht, ...)

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

add_rownames(ht, ...)

## S3 method for class '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.

Details

Note that add_colnames will change the mode of all columns to character. Also note that it will move your rows down by one: what was row 1 will now be row 2, and the column names will now be row 1.

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

Value

The modified object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
ht <- huxtable(
        First  = rnorm(5),
        Second = rnorm(5),
        add_rownames = FALSE
      )
add_rownames(ht)
add_colnames(ht)

# Out by 1:
add_rownames(add_colnames(ht))

# Better:
add_colnames(add_rownames(ht))

# Alternatively:
add_colnames(add_rownames(ht, ""))

huxtable documentation built on May 15, 2021, 1:09 a.m.