Closed mstackhouse closed 1 year ago
@elimillera when we can approve this update, I want to do a CRAN push as version 1.1.0, which is why I updated the version number.
@sadchla-codes I just added a new function - could you take a look? It's apply_conditional_formats()
and hopefully the function doc explains it well.
In practice, I see it being used as follows:
load(test_path('adsl.Rdata'))
t <- tplyr_table(adsl, TRT01P) %>%
add_layer(
group_count(RACE, by="Race n (%)") %>%
set_format_strings(f_str("xx (XX.x%)", n, pct))
)
dat <- t %>%
build()
# Replace whole string
dat %>%
mutate(
across(starts_with('var1'), ~ apply_conditional_format(., 2, x == 0, " 0 ", full_string=TRUE))
)
# Replace partial string
dat %>%
mutate(
across(starts_with('var1'), ~ apply_conditional_format(., 2, x < 1, "(<1%)"))
)
# Other use of across to demonstrate that non-numeric character strings are simply ignored
dat %>%
mutate(
across(where(is.character), ~ apply_conditional_format(., 2, x < 1, "(<1%)"))
)
@sadchla-codes sorry... I added new vignettes... Can you do some proofreading for me?
@mstackhouse I'm on it!
This PR incorporates all necessary updates to satisfy #117. Doc updates and unit testing updates have been satisfied.
Unit tests in test-num_fmt.R give a fuller example of the functionality, but a few examples of the functionality are as follows:
Some other notes:
f_str()$settings
parameter, so all of those unit tests had to be updated but I verified that the results all translated