Hello everyone,
I'm struggling with this problem, I want to add trailing zeros to a dt table but I need to do it with the options
parameter, I'm aware of %>% format_()
functions but I can't use this solution on my specific application, so I have the hope that this can be done with some JS()
code inside columnDefs
, I hope someone could help me.
This would be my desired output but keeping the class of the variables as numeric because I need to perform some calculations later.
library(DT)
library(dplyr)
iris %>%
mutate_if(is.numeric, ~sprintf(., fmt="%#.2f")) %>%
datatable()