Brilliant Slider Step by Step Login

I write brilliant and want a slider for the date. The date in my data is monthly, and I would like to take a step forward one month at a time. docs for entering the slider say that the step value is either in the second or in days, depending on the types of min / max parameters. I currently have:

sliderInput("slider", "Time", min=as.Date("2005-01-01"), max=as.Date("2014-12-01"), value=as.Date("2005-01-01"), step = 30,...) 

I want to be able to step by month, not day, but this does not seem possible from what they give me. Is there a js fragment that I could add that would give me this functionality?

Explanation Note: I have read the docs for this function and in the best way understand that there are no basic functions for this. When testing, the time format parameter changes only labels, not values. I saw a couple of posts that addressed the values โ€‹โ€‹of specific widgets and wondered if this was possible. For instance)

 <script type="text/javascript"> $(document).ready(function() { var slider = $("#slider").slider(); // override the default "nice" function. slider.nice = function(value) { var ref_date = new Date("2005-01-01"); // each slider step is 1 day, translating to 24 * 3600 * 1000 milliseconds var slider_date = new Date(ref_date.getTime() + value * 24 * 3600 * 1000); return [slider_date.getUTCFullYear(), slider_date.getUTCMonth() + 1, slider_date.getUTCDate()].join("-"); } }) 
+6
source share
1 answer

There is a timeFormat function in timeFormat . For more information, visit the Slider Input Widget .

EDIT:

To get the dates and use them later in my analysis, this question says a lot about the first day of the month from the POSIXct date using lubridate and the function provided by Roland.

 rm(list=ls()) library(shiny) monthStart <- function(x) { x <- as.POSIXlt(x) x$mday <- 1 as.Date(x) } ui <- basicPage(sliderInput("slider", "Time", min = as.Date("2010-01-01"),max =as.Date("2014-12-01"),value=as.Date("2014-12-01"),timeFormat="%b %Y"), textOutput("SliderText") ) server <- shinyServer(function(input, output, session){ sliderMonth <- reactiveValues() observe({ full.date <- as.POSIXct(input$slider, tz="GMT") sliderMonth$Month <- as.character(monthStart(full.date)) }) output$SliderText <- renderText({sliderMonth$Month}) }) shinyApp(ui = ui, server = server) 

enter image description here

+9
source

All Articles