Learn R Programming

rtables (version 0.4.0)

sprintf_format: Specify a rcell format based on sprintf formattig rules

Description

Format the rcell data with sprintf formatting strings

Usage

sprintf_format(format)

Arguments

format

character(1). A format string passed to sprintf.

Value

A formating function which wraps and will apply the specified printf style format string format.

See Also

sprintf

Examples

Run this code
# NOT RUN {
basic_table() %>%
  split_cols_by("ARM") %>%
  analyze("AGE", function(x) {
    in_rows(
      "mean_sd" = c(mean(x), sd(x)),
      "range" = range(x),
      .formats = c(mean_sd = sprintf_format("%.4f - %.2f"), range = "xx.xx - xx.xx")
    )
  }) %>%
  build_table(DM)

rcell(100, format = sprintf_format("(N=%i)"))

rcell(c(4,9999999999), format = sprintf_format("(%.2f, >999.9)"))

rtable(LETTERS[1:2], rrow("", 1 ,2), format = sprintf_format("%.2f"))

# }

Run the code above in your browser using DataLab