Skip to contents

crosstable 0.5.0 (?)

New features
  • New clean_names_with_labels() which clean 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.
  • 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.
  • 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
Bug fixes

crosstable 0.4.1 (2022-02-19)

CRAN release: 2022-02-25

  • Maintenance release to fix CRAN errors.

crosstable 0.4.0 (2022-02-14)

CRAN release: 2022-02-14

New features
  • You can now use basic markdown formats in body_add_normal(): **bold**, *italic*, _underlined_, and `code`.
  • New keep_id argument in compact.crosstable(), which enables as_flextable(compact=TRUE, keep_id=TRUE)
  • You can use as_flextable(header_show_n_pattern) to change the glue pattern of these group sizes. The default is {.col} (N={.n}); you can use {.col_key} and {.col_val} when by has multiple strata.
  • Functions body_add_table_legend() and body_add_figure_legend() earn an argument legend_prefix. Useful when set through global options, for instance to make every table/figure start with the name of the study.
  • crosstable_options() can handle new options for all those new features.
Improvements
  • You can now set normal style directly in body_add_normal() (it was only doable through options before).
  • Removed the “variable” header in compacted crosstables.
  • Dataset mtcars2 is now a tibble, with its rownames as a column named “model”.
  • as_flextable(by_header=FALSE) now removes the group header (if by has only one stratum).
  • as_flextable(header_show_n) now also works if by has multiple strata.
  • as_flextable(header_show_n=TRUE) adds group size for all groups.
Bug fixes
  • Fixed a bug when numeric variables are treated as categorical (failed if one had a NA value).
  • Fixed a bug that caused body_add_normal() to add an extra empty paragraph if there was a reference in the text.
  • Fixed a bug so that body_add_normal() can be used without argument.
  • Fixed a bug in effect=TRUE when some groups were present in table() but not in glm() due to missing values.

crosstable 0.3.2 (2021-11-27)

CRAN release: 2021-11-27

New features
  • Global options management is now easier thanks to crosstable_options() and autocompletion. Almost every argument can now be set using options. See ?crosstable_options for further details.
  • You can also use crosstable_peek_options() to see which crosstable option is currently set.
  • New argument num_digits in crosstable(). It was about time!
  • New argument header_show_n for as_flextable(), which adds the group size (N=xx) to the header of the flextable.
  • New arguments (and global options) par_before and par_after in respectively body_add_table_legend() and body_add_figure_legend(), which add an empty paragraph before/after the legend (for readability).
  • New function for {officer}: body_replace_text_at_bkms(), to replace several bookmarks at once.
  • New global option crosstable_options(crosstable_zero_percent=FALSE), which removes percentages whenever n==0 (as it would always be 0%). I should add it as an argument of crosstable() one day…
Improvements
Bug fixes
  • fixed a bug in crosstable() occurring when one of funs does not have ellipsis (…) and funs_arg contains an unused argument.

crosstable 0.3.1 (2021-11-14)

CRAN release: 2021-11-14

New features
  • New parameter percent_pattern in replacement of crosstable(margin=x) for better control over proportion format. Introduces the possibility of displaying confidence intervals (using Wilson score method) along with proportions.
  • New function body_add_crosstable_list() to add a list of crosstables all at once, separated by some customizable titles. Also works with flextables and plain old dataframes.
  • New argument crosstable_padding_v for as_flextable() to manage vertical padding. Also available as the global option crosstable_padding_v.
  • New global options crosstable_{arg} for almost all arguments. See ?crosstable_options for more details.
Bug fixes
  • fixed a bug in as_flextable() occurring when showNA=TRUE (header row was disappearing)
  • fixed a bug occurring very randomly, when rounding caused format_fixed() to return a numeric value (“Error: Can’t combine ..1$value and ..2$value .”)
  • crosstable now shows all unused levels in by when it is a factor
  • removed extra bold columns in compacted crosstables displayed as flextables
Internal
  • renamed branch master to main
  • use a lot more snapshots in tests

crosstable 0.2.2 (2021-10-18)

CRAN release: 2021-10-19

New features
  • Added support for multiple by! You can now write crosstable(mtcars, c(mpg, gear), by=c(am, vs)) %>% as_flextable().
  • Added a macro that can autofit every table in the document at once. This macro can be generated using the function generate_autofit_macro() which creates a file that should then be imported into MS Word.
  • body_add_crosstable() gains a padding_v argument to control the vertical padding of all rows.
  • body_add_title() and body_add_xxx_legend) gain a glue functionality. You can now write body_add_title("The iris dataset (nrow={nrow(iris)})", 1).
  • as_workbook() can now take a named list of crosstables, that will be considered as sheets.
  • New parameter percent in format_fixed(percent=TRUE/FALSE) to easily format percentages.
Minor changes
  • style is deprecated in body_add_table_legend() and body_add_image_legend() in favor of name_format.
  • Changed the behaviour of some effect calculations that were done by column instead of rows. That might change some outputs but not their meaning.
  • body_add_normal() now removes duplicated spaces (squish) in its input by default. Use squish=FALSE to override.
  • docx_bookmarks2() gains a target parameter.
Bug fixes
  • effect calculation now takes into account the reference level (first level of a factor).
  • body_add_crosstable() rightly takes body_fontsize and header_fontsize into account.
  • Added few more warnings, so that you know what went wrong.
Internal

crosstable 0.2.1 (2021-02-07)

CRAN release: 2021-03-08

  • First version on CRAN
  • Improved functions naming in funs, especially with multiple combinations of named and unnamed functions, including lambda or anonymous
  • Use simplify=FALSE in get_label() to get a list instead of a vector

crosstable 0.2.0 (2021-02-02)

Misc
  • added lots of global options for easier implementation. See ?crosstable_options for the comprehensive list.
  • added label helpers: apply_labels() (inspired by expss’s), copy_label_from() and rename_dataframe_with_labels()
  • added as_workbook() to export a crosstable as a formatted openxlsx Excel workbook, for copypasting purpose.
  • added peek() to open a crosstable in a temporary Word document, as copy-pasting in RStudio’s viewer is very limited.
  • fixed the bug when a columns contained both “NA” (string) and <NA> (missing).
  • fixed the bug where function in funs was not found if declared in another environment.
  • numerous other minor bugfixes and internal improvements.
Officer
Deprecations
  • Ellipsis (...) use in crosstable() has been deprecated for a more “tidy” syntax. Write crosstable(mtcars2, c(disp, vs)) instead of crosstable(mtcars2, disp, vs). Ellipsis will be defunct in future v1.0.
  • crosstable(.vars=) has been renamed to crosstable(cols=).
  • moystd() has been renamed to meansd().
  • body_add_glued() has been superseded by body_add_normal(), which inherits all functionalities and more.

crosstable 0.1.5 (2020-08-02)

crosstable 0.1.4 (2020-07-16)

crosstable 0.1.3 (2020-06-29)

  • Added support for description of Date variables. Format can be specified in funs_arg with the date_format key.
  • Removed some dependencies to ease installation

crosstable 0.1.2 (2020-06-10)

  • Effect refactoring: better error/warning handling
  • Name sanitation: replacing “.” by “_” in function names
  • Better error messages
  • Bug fixes

crosstable 0.1.1 (2020-06-07)

New features and behaviors
  • Added format_fixed(), rounding with the right number of decimals (including zeros)
  • Added import_labels(), which apply labels taken from a source dataframe (name, label) to another dataframe
  • Added margin="none" option, to remove percentages and keep only counts
  • Columns of unsupported class are dropped with a warning instead of failing with an error
Misc
  • Method cross_to_flextable() (ctf()) was deprecated and renamed as_flextable() (#207)
  • Reexporting pipes and tidyselect helpers so that user does not have to load these libraries
  • Computing time optimization (speed x2.6!)
  • Fixed bug in normality testing
  • Fixed bug in compact()

crosstable 0.1.0 (2020-04-09)

  • First release, big changes from the biostat2 package.