crosstable v0.6.0
New features
-
New function
transpose_crossable()
(or simplyt()
), which transposes a crosstable so that the labels and column names are swapped.ct = crosstable(mtcars2, c(mpg, drat, wt, qsec)) t_ct = t(ct) as_flextable(t_ct)
-
New function
pivot_crossable()
, which pivots a crosstable so that thevariable
column is spread as several columns.ct = crosstable(mtcars2, c(mpg, drat, wt, qsec)) p_ct = pivot_crosstable(ct) as_flextable(p_ct)
-
body_add_table_list()
now replacesbody_add_crosstable_list()
andbody_add_flextable_list()
. It allows both crosstables and flextable (and even dataframes, which are turned to flextables first) and has a new argumentfun_after
to control what comes after the table. See examples in?body_add_table_list
. -
New function
get_percent_pattern()
. See also the new vignettevignette("percent_pattern")
. -
New argument
crosstable(drop_levels=TRUE)
to drop unused levels in factors. -
copy_label_from()
now works on dataframes as well. -
as_flextable(header_show_n_pattern)
can now be a list of namescell
andtotal
, so that the "Total" column can be labelled too.
Breaking changes (minor)
-
showNA="no"
is now consistent withstats::addmargins()
,gtsummary::tbl_cross(missing="no")
, andjanitor::tabyl(show_na=FALSE)
. It now actually removes allNA
from the equation, instead of not doing much (#24). -
In
percent_patern
, the proportion relative to the total samplep_cell
has been renamed top_tot
for clarity.
Bug fixes and improvements
- Removed unexpected warning "NaNs produced" thrown when calculating percentages in totals while the number of NA is higher than the other classes (#20).
- The output is now correct when
header_show_n=TRUE
andremove_header_keys=TRUE
while using multiple by variables (#21). - Flextables will not have missing columns when using multiple by variables that has same key levels.
- String interpolation works as intended in
body_add_xxx_legend()
. crosstable()
will not fail iffisher.test()
fails [#28]forcats::fct_explicit_na()
is not used anymore [#29]body_add_normal()
now removes ``` symbols when showing code [#31]- Trailing commas will not make
apply_labels()
fail anymore [#32] - Performance improvement (around 30% for small tables) as confidence intervals are not calculated anymore when not needed [#34]
Many thanks to Stephan Daus (@sda030) for his bug reports and feedback on this release.