Learn R Programming

crosstable (version 0.8.0)

as_gt.crosstable: Converts a crosstable object into a formatted gt table.

Description

Converts a crosstable object into a formatted gt table.

Method to convert an object to a gt table

Default method to convert an object to a gt table

Usage

# S3 method for crosstable
as_gt(
  x,
  show_test_name = TRUE,
  by_header = NULL,
  keep_id = FALSE,
  generic_labels = list(id = ".id", variable = "variable", value = "value", total =
    "Total", label = "label", test = "test", effect = "effect"),
  ...
)

as_gt(x, ...)

# S3 method for default as_gt(x, ...)

Value

a formatted gt table

Arguments

x

object to be converted

show_test_name

in the test column, show the test name

by_header

a string to override the by header

keep_id

whether to keep the .id column

generic_labels

names of the crosstable default columns

...

arguments for custom methods

Methods (by class)

  • as_gt(crosstable): For crosstables

  • as_gt(default): default function

Author

Dan Chaltiel

See Also

as_flextable.crosstable()

gt::gt()

Examples

Run this code
xx = mtcars2 %>% dplyr::select(2:10)
crosstable(xx) %>% as_gt
crosstable(xx, by=am) %>% as_gt
crosstable(xx, by=cyl, test=TRUE, total=TRUE) %>%
   as_gt(keep_id=TRUE, show_test_name=FALSE, by_header="Cylinders")

Run the code above in your browser using DataLab