rashid rashid - 1 month ago 45
R Question

How to display numbers in percent format?

How can I change the number format of widgets in Shiny?

I have a slider going from 0 to 1 but I'd prefer having it going from 0% to 100%. I know I could just multiply the numbers by 100 but then I would still not be able to display numbers in percent. Is it possible to do so?

EDIT
Since this was marked as a duplicate: the other post proposed that one uses

format =
but R tells me that piece of codes is depreciated.

Answer

You can use the post argument to sliderInput.

http://shiny.rstudio.com/reference/shiny/latest/sliderInput.html

library(shiny)

ui <- shinyUI(
  fluidPage(
    sliderInput("mySlider",label="my slider", min = 0, max = 100, post  = " %", value = 50)
  )
)

server <- shinyServer(function(input, output) {

})

shinyApp(ui=ui, server=server)
Comments