Skip to content

Commit

Permalink
Make several refactoring improvements to some format_*() functions (#…
Browse files Browse the repository at this point in the history
…244)

* Add comment with a TODO

* Refactor stmt in `fmt_percent()`

* Remove unneeded stmt

* Use different function call

* Remove unneeded util function

* Remove unneeded components in `switch()`

* Remove unneeded util function

* Remove extra space

* Update several testthat tests

* Make handling of parentheses consistent

* Rename `paste_currency_str()` to be general

* Use the `paste_symbol_str()` util fcn

* Create a common `symbol_str` variable

* Modify several testthat tests

* Add the `perform_negative_formatting()` fcn

* Simplify negative value formatting

* Modify the `to_latex_math_mode()` fcn

* Modify calls to `to_latex_math_mode()`

* Incorporate `minus_mark` in `paste_symbol_str()`

* Add a function factory for some `format_*()` fcns

* Define the formatter `type` for some `format_*()` fcns

* Remove `negative_val` arg in some `format_*()` fcns

* Use the `num_formatter_factory()` fcn factory

* Update help files using roxygen

* Remove several unneeded testthat tests

* Modify argument name

* Update repeated function calls

* Modify function name

* Modify comment

* Modify conditional statement

* Update argument in function signature

* Modify variable assignment

* Modify function called

* Update help file using roxygen

* Update several testthat tests

* Remove `x` from fcn signature

* Modify roxygen documentation

* Set default values

* Reverse order of args in fcn signature

* Update help file using roxygen

* Add argument to fcn signature

* Remove unneeded util function

* Return early in certain circumstances

* Reverse order of args in fcn signature

* Use `x` in fcn body instead of `x_str_vals`

* Add the `prettify_scientific_notation()` util fcn

* Add a `force()` call for each arg

* Refactor the `num_formatter_factory()` fcn

* Avoid assigning the `type` variable

* Call the `normalize_suffixing_inputs()` fcn

* Modify all `num_formatter_factory()` calls

* Modify two testthat tests

* Modify roxygen documentation

* Update help files using roxygen

* Remove default `NULL` values in fcn signature

* Apply series of transformations with `%>%`

* Assign logical vector `x_vals_lt0` for reuse

* Force all arguments using a list

* Move references of `currency` to `symbol`

* Use `symbol` in place of `currency`

* Add roxygen documentation and comments

* Modify roxygen documentation

* Update help files using roxygen

* Validate a non-NULL locale right away

* Modify function name

* Simplify signature of `num_fmt_factory()`

* Extract variables from `var_list`

* Add the `create_var_list()` util fcn

* Remove unneeded code

* Simplify transformations in function factory

* Modify function signatures

* Generate `sep|dec_mark` within function factory

* Refactor several `fmt_*()` functions

* Modify function signature

* Use `num_fmt_factory_multi()` throughout

* Add roxygen documentation

* Remove the `contexts` arg

* Refactor `fmt_*()` fcns

* Refactor `fmt_*()` fcns

* Tidy code and add roxygen documentation

* Additional refactoring for `format_*()` functions (#260)

* Get `minus_mark` just before usage

* Get `parens_marks` just before usage

* Get `symbol_str` just before usage
  • Loading branch information
rich-iannone authored Apr 18, 2019
1 parent 49df7fb commit 1f8f97b
Show file tree
Hide file tree
Showing 30 changed files with 733 additions and 659 deletions.
622 changes: 250 additions & 372 deletions R/format_data.R

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,13 @@ markdown_to_text <- function(text) {
#' final decoration of the formatted values. We use \pkg{glue}'s semantics here
#' and reserve \code{x} to be the formatted values, and, we can use \code{x}
#' multiple times in the pattern.
#' @param pattern A formatting pattern that allows for decoration of the
#' formatted value (defined here as \code{x}).
#' @param values The values (as a character vector) that are formatted within
#' the \code{fmt_*()} function.
#' @param pattern A formatting pattern that allows for decoration of the
#' formatted value (defined here as \code{x}).
#' @noRd
apply_pattern_fmt_x <- function(pattern,
values) {
apply_pattern_fmt_x <- function(values,
pattern) {

vapply(
values,
Expand Down
Loading

0 comments on commit 1f8f97b

Please sign in to comment.