Skip to contents

stm_gtable() converts the provided data to a tibble, replaces any missing values with a dash ("-"), and generates a styled table using the gt package. It applies borders, alignment, and other custom styles to the table's body and column labels.

Usage

stm_gtable(dat)

Arguments

dat

A data frame or tibble to be converted into a styled table. It will be converted to a tibble if necessary.

Value

A `gt` table object with styling applied. The table will have missing values replaced with a dash ("-"), cell borders, and left alignment for character columns.

Details

The function performs the following operations:

  • Converts the input data into a tibble using tibble::as_tibble().

  • Replaces any missing values in the data with a dash ("-") using tidyr::replace_na().

  • Creates a table using the gt::gt() function.

  • Applies cell border styles to the body and column labels of the table.

  • Left-aligns character columns and applies additional styling such as padding and bold column labels.

See also

Examples

tbl <- tibble::tibble(
  Name = c("John", "Jane", "Doe"),
  Age = c(25, 30, NA),
  City = c("New York", "Los Angeles", "Chicago")
)
stm_gtable(tbl)
Name Age City
John 25 New York
Jane 30 Los Angeles
Doe
Chicago