# NOT RUN {
#Crosstables
library(crosstable)
library(dplyr)
crosstable_options(crosstable_fontsize_header=14,
crosstable_fontsize_subheaders=10,
crosstable_fontsize_body=8)
crosstable(iris) %>% as_flextable()
crosstable(mtcars2, by=c(am, vs)) %>% as_flextable()
crosstable(mtcars2, cols=c(mpg, cyl), by=am, effect=TRUE) %>%
as_flextable(keep_id=TRUE, autofit=FALSE)
crosstable(mtcars2, cols=c(mpg, cyl), by=am, effect=TRUE) %>%
as_flextable(compact=TRUE)
#Renaming (because why not?)
crosstable(mtcars2, by=vs, total="both", test=TRUE, effect=TRUE) %>%
rename(ID=.id, math=variable, Tot=Total, lab=label, pval=test, fx=effect) %>%
as_flextable(by_header = "Engine shape",
generic_labels=list(id = "ID", variable = "math", total="Tot",
label = "lab", test = "pval", effect="fx"))
# }
Run the code above in your browser using DataLab