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 class '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, ...)
# Default S3 method
as_gt(x, ...)
Examples
xx = mtcars2 %>% dplyr::select(2:10)
crosstable(xx) %>% as_gt
value
Miles/(US) gallon
Min / Max
Med [IQR]
Mean (std)
N (NA)
Number of cylinders
4
6
8
Displacement (cu.in.)
Min / Max
Med [IQR]
Mean (std)
N (NA)
Gross horsepower
Min / Max
Med [IQR]
Mean (std)
N (NA)
Rear axle ratio
Min / Max
Med [IQR]
Mean (std)
N (NA)
Weight (1000 lbs)
Min / Max
Med [IQR]
Mean (std)
N (NA)
1/4 mile time
Min / Max
Med [IQR]
Mean (std)
N (NA)
Engine
straight
vshaped
Transmission
auto
manual
crosstable(xx, by=am) %>% as_gt
#> Warning: Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead
#> Warning: Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead
#> Warning: Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead
#> Warning: Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead
#> Warning: Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead
#> Warning: Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead
auto
manual
Miles/(US) gallon
Min / Max
Med [IQR]
Mean (std)
N (NA)
Number of cylinders
4
6
8
Displacement (cu.in.)
Min / Max
Med [IQR]
Mean (std)
N (NA)
Gross horsepower
Min / Max
Med [IQR]
Mean (std)
N (NA)
Rear axle ratio
Min / Max
Med [IQR]
Mean (std)
N (NA)
Weight (1000 lbs)
Min / Max
Med [IQR]
Mean (std)
N (NA)
1/4 mile time
Min / Max
Med [IQR]
Mean (std)
N (NA)
Engine
straight
vshaped
crosstable(xx, by=cyl, test=TRUE, total=TRUE) %>%
as_gt(keep_id=TRUE, show_test_name=FALSE, by_header="Cylinders")
#> Warning: Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead
#> Warning: Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead
#> Warning: Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead
#> Warning: Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead
#> Warning: Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead
#> Warning: Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead
4
6
8
Miles/(US) gallon (`mpg`)
Min / Max
Med [IQR]
Mean (std)
N (NA)
Displacement (cu.in.) (`disp`)
Min / Max
Med [IQR]
Mean (std)
N (NA)
Gross horsepower (`hp`)
Min / Max
Med [IQR]
Mean (std)
N (NA)
Rear axle ratio (`drat`)
Min / Max
Med [IQR]
Mean (std)
N (NA)
Weight (1000 lbs) (`wt`)
Min / Max
Med [IQR]
Mean (std)
N (NA)
1/4 mile time (`qsec`)
Min / Max
Med [IQR]
Mean (std)
N (NA)
Engine (`vs`)
straight
vshaped
Total
Transmission (`am`)
auto
manual
Total