Skip to contents

Format numeric cells in a flextable.

Usage

colformat_double(
  x,
  i = NULL,
  j = NULL,
  big.mark = get_flextable_defaults()$big.mark,
  decimal.mark = get_flextable_defaults()$decimal.mark,
  digits = get_flextable_defaults()$digits,
  na_str = get_flextable_defaults()$na_str,
  nan_str = get_flextable_defaults()$nan_str,
  prefix = "",
  suffix = ""
)

Arguments

x

a flextable object

i

rows selection

j

columns selection.

big.mark, digits, decimal.mark

see formatC()

na_str, nan_str

string to be used for NA and NaN values

prefix, suffix

string to be used as prefix or suffix

Examples

dat <- mtcars
ft <- flextable(head(dat))
ft <- colformat_double(
  x = ft,
  big.mark = ",", digits = 2, na_str = "N/A"
)
autofit(ft)

mpg

cyl

disp

hp

drat

wt

qsec

vs

am

gear

carb

21.00

6.00

160.00

110.00

3.90

2.62

16.46

0.00

1.00

4.00

4.00

21.00

6.00

160.00

110.00

3.90

2.88

17.02

0.00

1.00

4.00

4.00

22.80

4.00

108.00

93.00

3.85

2.32

18.61

1.00

1.00

4.00

1.00

21.40

6.00

258.00

110.00

3.08

3.21

19.44

1.00

0.00

3.00

1.00

18.70

8.00

360.00

175.00

3.15

3.44

17.02

0.00

0.00

3.00

2.00

18.10

6.00

225.00

105.00

2.76

3.46

20.22

1.00

0.00

3.00

1.00