Learn R Programming

flextable (version 0.4.6)

colformat_num: format numeric columns

Description

Format numeric columns in a flextable or regulartable.

Usage

colformat_num(x, col_keys, big.mark = ",", digits = 2, na_str = "",
  prefix = "", suffix = "")

Arguments

x

a regulartable object

col_keys

names of the colkeys

big.mark, digits
na_str

string to be used for NA values

prefix

string to be used as prefix or suffix

suffix

string to be used as prefix or suffix

See Also

Other columns formatters: colformat_char, colformat_int

Examples

Run this code
# NOT RUN {
dat <- iris
dat[1:4, 1] <- NA
dat[, 2] <- dat[, 2] * 1000000

ft <- regulartable(dat)
colkeys = c("Sepal.Length", "Sepal.Width",
            "Petal.Length", "Petal.Width")
ft <- colformat_num(
  x = ft, col_keys = colkeys,
  big.mark=",", digits = 2, na_str = "N/A")
autofit(ft)

ft <- flextable(dat)
colkeys = c("Sepal.Length", "Sepal.Width",
            "Petal.Length", "Petal.Width")
ft <- colformat_num(
  x = ft, col_keys = colkeys,
  big.mark=",", digits = 2, na_str = "N/A")
autofit(ft)
# }

Run the code above in your browser using DataLab