Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
524 views
in Technique[技术] by (71.8m points)

r - Formatting number output of sliderInput in shiny

A good example of my question is found in the Movie Review example in the Shiny Gallery here:

http://shiny.rstudio.com/gallery/movie-explorer.html

There is a slider on the left hand side panel called "Year Released" which ranges between 1940 and 2014. Here is the code for it from the ui.R

sliderInput("year", "Year released", 1940, 2014, value = c(1970, 2014))

You will notice that the formatting of the years when you use the slider are of the form:

"1,940" "2,014" with a comma separating the first digit from the last three.

I know that one can use dateRangeInputin Shiny but this requires the variable to be in a date format. For data variables that are simply numbers referring to years such as this example, is there a simple way to format the number output to remove the comma? I can't seem to figure this out, something that seems simple.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

More recent releases of shiny throw the following error if one uses a format argument:

The format argument to sliderInput is deprecated. Use sep, pre, and post instead. (Last used in version 0.10.2.2)

Now the preferred argument is evidently sep = ""


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...