huxtable format number with formatC

74 views Asked by At

I want to create table with library huxtable where number will be in format as:

input= 10000000; output = 1000.000,0

For example:

library(data.table)
library(huxtable)
a=data.table(id="a",num=100.0)

If i use:

formatC(a$num, format = "f", big.mark = ".", digits = 1, decimal.mark = ",",drop0trailing = FALSE)

I get 100,0

but if i use this in huxtable:

as_huxtable(a)|>
set_number_format(row= 1,col = 2,value=
                    list(function(x) {
                      formatC(x, format = "f", big.mark = ".", digits = 1, decimal.mark = ",",drop0trailing = FALSE)
                    }))

I get 100

Edit: Its working, my mistake. I choosed header of column and not value. Instead row= 1, col = 2 it should have been row= 2, col = 2.

0

There are 0 answers