1
votes

I have created a sliderInput in UI.R

fluidRow(column(4,
                uiOutput("showMapPlot"),
                wellPanel(
                    sliderInput("slider", label = h4("Time (Hours)"), min = 1, max = 552, value = c(10,50),animate = FALSE, width="70%", format = "#")
                  ), ...................

and I am passing the input$slider1 and input$slider[2] into server.R and where I am plotting some graphs using ggplot function.

The function is like below

plot_1 <- function() {
        var = input$select
        gg1 <- aggregate(cbind(get(var)) ~ Mi + hours , a, FUN=mean)
        names(gg1)[3] <- var
        print(ggplot(gg1, aes_string(x = "hours", y = var, group = "Mi")) +
                geom_point(aes(color = factor(Mi))) + geom_smooth(stat= "smooth" , alpha = I(0.4), method="loess",color="grey", formula = y ~ x) 

How to access the slider inputs from the UI.r and update in realtime with the server.R. I want to recursively change the x axis values according to the slider input values.

I know the dataset a in the expression

gg1 <- aggregate(cbind(get(var)) ~ Mi + hours , a, FUN=mean)

should alter somehow to access the data in the range of slider inputs. I dont know where should I implement it. I tried to update within this function itself and it did not work. I tied withing renderUI and there also it did not work, and mostly the method was wrong.

Please if someone knows the solution let me know.

The data is given below. https://drive.google.com/file/d/0B54s5NXDypdMRmdsSjZnMzd5VVE/edit?usp=sharing

and object a is created priori like "a <- read.table(file=file.choose(), header=FALSE,col.names= c("Ei","Mi","hours","Nphy","Cphy","CHLphy","Nhet","Chet","Ndet","Cdet","DON","DOC","DIN","DIC","AT","dCCHO","TEPC","Ncocco","Ccocco","CHLcocco","PICcocco","par","Temp","Sal","co2atm","u10","dicfl","co2ppm","co2mol","pH")) "

1
I am not sure I understand what you are asking. Do you want the graph to change based on the slider values? Or are you trying to update the slider to have different values to choose from?John Paul
@JohnPaul Thanks for the reply. Sorry if my explanation is not perfect. Your first assumption is correct. I am trying change the graph based on the slider values that user selects from the browser.cppiscute

1 Answers

1
votes

I don't really know ggplot, but your slider will give you two values input$slider[1] and input$slider[2] which will be the min and max respectively. If you want to change the limits of the x-axis, I think you use

 + xlim(input$slider[1],input$slider[2]) 

in your ggplot() command.