Setting round does not directly affect the number of digits (although some indirect effect is associated with a potential return of digits of a negligible ( 0 )). The main problem here is that pander does not allow you to set the nsmall format() parameter, which would set
minimum number of digits to the right of the decimal point when formatting real / complex numbers in non-scientific formats. Allowed values: 0 <= nsmall <= 20.
But since pander only feeds numeric values to format() , you can just work around this by supplying the values of as.character() to pander:
library (data.table) library(magrittr) library (pander) set.seed(1984) longString <- "description string" dt <- data.table(id = c(1:3), description = rep(longString, 3), value = rnorm(3, mean = 10000, sd = 1)) pander( x = dt %>% mutate(value = value %>% round(2) %>% as.character()), split.cell = 80, split.table = Inf, justify = "ccr" )
that leads to:
------------------------------------ id description value ---- -------------------- ---------- 1 description string 10000.41 2 description string 9999.68 3 description string 10000.64 ------------------------------------
source share