Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I need to display the data in my table for 3 decimal places but it turns out that it doesn't display 3 decimal places when I run my application. Though when I try to interact with it it displays 3 decimal places.

Is there any way to do this?

like image 353
Achilles Ebron Avatar asked Jun 24 '15 09:06

Achilles Ebron


1 Answers

You can use DT::formatRound function. It take list of columns and number of digits to render:

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 about using DT::renderDataTable in the server function and DT::dataTableOutput in the UI.

like image 122
zero323 Avatar answered Sep 28 '22 09:09

zero323