Skip to content

crosstable v0.5.0

Compare
Choose a tag to compare
@DanChaltiel DanChaltiel released this 22 Aug 19:07
· 311 commits to main since this release

New features

  • New clean_names_with_labels() which cleans the names of the dataframe but keeps the old names as labels. Obviously inspired by {janitor}.
  • New variables n_col, n_row, and n_tot available for percent_pattern. Also, every variable has now its counterpart with the _na suffix which accounts for missing values.
    For instance, one can now write:
    crosstable(mtcars2, cyl, percent_pattern="{p_col} ({n}/{n_col}) [95%CI: {p_col_inf}; {p_col_sup}]")
    crosstable(mtcars2, cyl, percent_pattern="{p_col_na} ({n}/{n_col_na}) [95%CI: {p_col_inf}; {p_col_sup}]")
  • percent_pattern can now be a list of characters with names body, total_row, total_col, and total_all to also control the pattern in other parts of the crosstable than the body.

Improvements

  • crosstable_options() does not need the "crosstable_" prefix anymore, so the autocomplete is less clumsy. Options with the prefix will still work though. crosstable_options(reset=TRUE) is deprecated in favor of the new crosstable_reset_options().
  • crosstable_test_args() and crosstable_effect_args() now have arguments to easily control the non-default parameters.
  • Allow scientific notation for big numbers. Default to numbers for which abs(log10(x))>4. This can be controlled using options, e.g. crosstable_options(scientific_log=5).
  • In MS Word, crosstables will now break across pages by default. You can revert this by using body_add_crosstable(allow_break=FALSE) or using crosstable_options(). This is the pendant of keepnext in officer/flextable.
  • New argument body_add_crosstable(max_cols=25), which limits the size of crosstables in Word documents. This prevents very large tables to be wrongly included.
  • peek() is now usable on non-crosstable objects as well. as_flextable() method will be applied on the object if available, otherwise flextable() will be applied.
  • Better error messages in import_labels() when data_label doesn't have the right columns.

Deprecations

  • rename_dataframe_with_labels() is now deprecated in favor of the better named rename_with_labels().
  • compact() is now deprecated in favor of ct_compact() to avoid the conflict with purrr::compact(). It will be removed in the next version.

Bug fixes

  • body_add_crosstable(..., parse=NULL) will now work as intended .
  • by_header can replace the "value" column if by has only one stratum, in both as_gt() and as_flextable() (#9).
  • percent_pattern can now contain functions that start by "p" (#10).
  • percent_pattern is actually taken into account when by has one single level (#13).
  • import_labels() now works even if there is a missing value in the dataframe.
  • Minor other bugfixes