r - plotting points within a date range specified with shiny slider bar -


from larger dataset, want plot points within min , max date specified shiny slider bar containing date range. post builds related post linked here. data contained @ bottom using dput.

the code/app below sequentially plots points date increased slider bar. when move 2nd slider bar want points no longer in date range removed, currenlty not happen.

how subset data points (and paths) >= min date , <= max date shown? not clear me how reference 2 dates on slider bar.

thanks in advance.

library(ggplot2) library(shiny) ui <- fluidpage(   titlepanel("gps data summary"),   sliderinput(inputid = "order",               label = "sequance of observations",                 min = as.date(min(dat$posigmt)), max = as.date(max(dat$posigmt)),                value = c(as.date(min(dat$posigmt)), as.date(min(dat$posigmt)))),   plotoutput("pointplot") )  server <- function(input, output) {   output$pointplot <- renderplot({     p <- ggplot(dat[as.date(dat$posigmt) <= input$order ,], (aes(x = gpsutmeasting , y = gpsutmnorthing ))) +        geom_point() + geom_path() +        xlim( min(dat$gpsutmeasting), max(dat$gpsutmeasting))+       ylim( min(dat$gpsutmnorthing), max(dat$gpsutmnorthing))     print(p)   }) }   shinyapp(ui = ui, server = server) 

data below

dat <- structure(list(gpsutmnorthing =      c(4947787l, 4947945l, 4947957l,       4947954l, 4947797l, 4947835l, 4947825l, 4947784l, 4947842l, 4947839l,       4947789l, 4947807l, 4947839l, 4947845l, 4947779l, 4947824l, 4947824l,       4947772l, 4947824l, 4947821l, 4947816l, 4947809l, 4947840l, 4947829l,       4947820l),       gpsutmeasting = c(600201l, 600910l, 600911l, 600907l,                        601052l, 601038l, 601031l, 601066l, 600998l, 600995l, 601058l,                        601038l, 600987l, 601071l, 601016l, 601002l, 601003l, 601003l,                        600917l, 600916l, 600918l, 600923l, 600985l, 600980l, 600914l),      posigmt = structure(c(1360393200, 1360414800, 1360479600,                    1360501200, 1360544400, 1360566000, 1360587600, 1360630800, 1360652400,                    1360674000, 1360695600, 1360717200, 1360738800, 1360803600, 1360825200,                    1360846800, 1360868400, 1360890000, 1360911600, 1360933200, 1360954800,                    1360976400, 1360998000, 1361019600, 1361041200),                    class = c("posixct", "posixt"), tzone = "") ),                    .names = c("gpsutmnorthing", "gpsutmeasting", "posigmt"),        row.names = c(1l, 2l, 5l, 6l, 8l, 9l, 10l, 12l, 13l, 14l, 15l,                    16l, 17l, 20l, 21l, 22l, 23l, 24l, 25l, 26l, 27l, 28l, 29l, 30l, 31l),                    class = "data.frame") 

hi input$order vector of length 2, input$order[1] min , input$order[2] max, can :

library(ggplot2) library(shiny) ui <- fluidpage(   titlepanel("gps data summary"),   sliderinput(inputid = "order",               label = "sequance of observations",                 min = as.date(min(dat$posigmt)), max = as.date(max(dat$posigmt)),                value = c(as.date(min(dat$posigmt)), as.date(min(dat$posigmt)))),   plotoutput("pointplot") )  server <- function(input, output) {   output$pointplot <- renderplot({     ### filter date     dat <- dat[as.date(dat$posigmt) >= input$order[1] & as.date(dat$posigmt) <= input$order[2] ,]     ###     p <- ggplot(dat, (aes(x = gpsutmeasting , y = gpsutmnorthing ))) +        geom_point() + geom_path() +        xlim( min(dat$gpsutmeasting), max(dat$gpsutmeasting))+       ylim( min(dat$gpsutmnorthing), max(dat$gpsutmnorthing))     print(p)   }) }   shinyapp(ui = ui, server = server) 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -