Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display numbers in percent format? [duplicate]

Tags:

r

shiny

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.

like image 410
Cactus Avatar asked Oct 10 '16 11:10

Cactus


People also ask

How do you format results as percent style?

On the Home tab, in the Number group, click the icon next to Number to display the Format Cells dialog box. In the Format Cells dialog box, in the Category list, click Percentage. In the Decimal places box, enter the number of decimal places that you want to display.

How do I turn a number into a percentage?

To convert a decimal to a percentage, multiply by 100 (just move the decimal point 2 places to the right). For example, 0.065 = 6.5% and 3.75 = 375%. To find a percentage of a number, say 30% of 40, just multiply. For example, (30/100)(40) = 0.3 x 40 = 12.

How do you show a number as a percentage in Excel?

To show a number as a percent in Excel, you need to apply the Percentage format to the cells. Simply select the cells to format, and then click the Percent Style (%) button in the Number group on the ribbon's Home tab. You can then increase (or decrease) the the decimical place as needed.

How do I convert a number to a percentage in Excel without multiplying by 100?

If you want to add percentage sign to a number without multiplying the number by 100, such as to change 6 into 6% in Excel with Percentage Style, you should have the general number divided by 100 first, and then apply the Percentage Style to the numbers for displaying them as percentage 6% in Excel.


1 Answers

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)
like image 174
nilsole Avatar answered Oct 19 '22 19:10

nilsole