Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend examples and see also of sprintf_format function #269

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions R/format_value.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,19 @@ check_aligns <- function(algn) {
#' @export
#' @return A formatting function which wraps and will apply the specified \code{printf} style format
#' string \code{format}.
#' @seealso \code{\link[base]{sprintf}}
#'
#' @seealso \code{\link[base]{sprintf}} [round_fmt()] \code{link{list_formats}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martincadek could you make it all [fnc()] please? Also can you go in the other functions and see that they have some good connection with this one? otherwise it remains difficult to reach

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should also be a counterpart in {rtables} with links to these in some of the obscure description of parameters. All of this would make a nice extension of the current vignette on format precedence

#' @examples
#' fmtfun <- sprintf_format("(N=%i")
#' format_value(100, format = fmtfun)
#'
#' fmtfun2 <- sprintf_format("%.4f - %.2f")
#' format_value(list(12.23456, 2.724))
#'
#' fmtfun3 <- sprintf_format("this range => %.1f")
#' format_value(100, format = fmtfun3)
#'
#' fmtfun4 <- sprintf_format("sadbasd asa a %.2f asda a %.1f")
#' format_value(list(12.23456, 2.724), format = fmtfun4)
sprintf_format <- function(format) {
function(x, ...) {
do.call(sprintf, c(list(fmt = format), x))
Expand Down
8 changes: 7 additions & 1 deletion man/sprintf_format.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading