title: How to display numbers in renderTable with the correct number of decimal places?
body: <p>In my <code>shiny</code> app I have a <code>renderTable</code> filled with whole numbers as well as decimal numbers. My goal is to display the whole numbers without any decimal place, i. e. 1 should be displayed as "1", and the decimal numbers with all decimal places, i. e. 1.2345 should be displayed as "1.2345". I should mention that the numbers stem from user input. Thus, I do not know in advance how many decimal places they will have. Please see the following example:</p>
  
  <pre><code>library(shiny)
  
  ui &lt;- fluidPage(
    numericInput("number", "enter a number", value = 1.2345),
    tableOutput("table"))
  
  server &lt;- function(input, output, session) {
    output$table &lt;- renderTable({data.frame(c(1, input$number))}, digits = 0)}
  
  shinyApp(ui, server)
  </code></pre>
  
  <p>As you can see I am aware of the <code>digits</code> argument of <code>renderTable</code>, but I do not see how to make use of it in my case.</p>