Implement adorn_* functions for tabyl formatting #1563
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
adorn_*family of functions from R janitor for formatting frequency tables (tabyls) into publication-ready tables. These functions are designed to be chained together in a fluent interface.Closes #1557
Functions Implemented
1.
adorn_totals(where="row", fill="-", na_rm=True, name="Total")Add totals row and/or column to a DataFrame.
2.
adorn_percentages(denominator="row", na_rm=True)Convert counts to percentages (row-wise, column-wise, or overall).
3.
adorn_pct_formatting(digits=1, rounding="half to even", affix_sign=True)Format decimal percentages as "XX.X%" strings.
4.
adorn_ns(position="rear", ns=None, format_func=None)Append the original N counts to formatted percentage cells.
5.
adorn_title(placement="top", row_name=None, col_name=None)Add variable name as title to a cross-tabulation.
6.
adorn_rounding(digits=1, rounding="half to even")Round numeric columns with configurable rounding method.
Full Pipeline Example
Testing
Implementation Notes
adorn_nsto access