I have a Shiny app with numerous numericInput
fields. I would like a way to format the numericInput
fields with commas separating every 10^3. For example, I want 5,000,000 instead of 5000000.
I can do this in R with the format
and prettyNum
functions. But I don't have a way to do this in Shiny.
This would be very helpful for the UI because it would work with percents, money, etc. Does anyone have any idea how to incorporate this into the numericInput
field?
Thanks!
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
mainPanel(
numericInput("formatNumber",
"Number should be formatted, e.g."5,000,000",
value = 1000),
p(format(5000000.10, big.mark=",", big.interval=3L,
digits=0, scientific=F))
)
)
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
js
solution. – ismirsehregal