How to always display 3 decimal places in DataTables in R Shiny?

I need to display the data in my table by 3 decimal places, but it turned out that when I launch my application, it does not display 3 decimal places. Although, when I try to interact with it, it displays 3 decimal places.

Is there any way to do this?

+4
source share
1 answer

You can use the DT::formatRound . To display a list of columns and the number of digits:

 library(DT) set.seed(323) data.frame(x=runif(10), y=rnorm(10), z=rpois(10, 1)) %>% datatable() %>% formatRound(columns=c('x', 'y'), digits=3) 

enter image description here

Just remember to use DT::renderDataTable in the server function and DT::dataTableOutput in the user interface.

+10
source

Source: https://habr.com/ru/post/1211656/


All Articles