library(crosstable)
crosstable(mtcars2, c(mpg, drat, wt, qsec), by=am) %>%
t() %>% as_flextable(compact=FALSE)

crosstable(mtcars2, c(mpg, drat, wt, qsec), by=am) %>%
t() %>% as_flextable(compact=TRUE)
#> Error in `mutate()`:
#> ℹ In argument: `variable = ifelse(.data$gp, label, variable)`.
#> Caused by error:
#> ! object 'label' not found
Created on 2024-12-11 with reprex v2.1.1
Also, add a hint to the pivot_ct() error when by is not null: "Do you need t()?"