Skip to contents

Apply uniform formatting to numeric columns

Usage

format_dataframe(
  df,
  numeric_fmt = "%.2f",
  pval_cols = NULL,
  output_format = "dataframe",
  title = ""
)

Arguments

df

Data frame.

numeric_fmt

sprintf-style format spec without leading "%".

pval_cols

Columns to format as p-values.

output_format

Output target.

title

Title.

Value

A character string.

Examples

df <- data.frame(est = c(1.234, 2.456), p = c(0.001, 0.5))
format_dataframe(df, pval_cols = "p")
#>    est     p
#> 1 1.23 0.001
#> 2 2.46 0.500