I guys, i'm actually trying to add a zoom function on my plot but I don't understand how to do it, can someone help me please? I used the shiny zoom tutoriel but never made it work (https://shiny.rstudio.com/gallery/plot-interaction-zoom.html)
This is my code, thanks in advance :
ui = fluidPage(
sidebarLayout(
sidebarPanel(
fileInput("inputFile", "Browse for file",multiple = TRUE),
uiOutput("plot.params")
),
mainPanel(
tabsetPanel(
tabPanel("graph",plotOutput("plot"))
)
)
)
)
server<-function(input, output, session) {
data_set <- reactive({
if(is.null(input$inputFile)){
return(NULL)}
data_set<-read.table(input$inputFile$datapath,sep=";",header = FALSE)
})
output$plot.params <- renderUI({ list(
selectInput(inputId = "xaxisGrp", label = "X", choices = names(data_set() )) ,
selectInput(inputId = "yaxisGrp", label = "Y", choices = names(data_set() ))
)})
output$plot = renderPlot({
df <- data_set()
gp <- NULL
if (!is.null(df)){
xv <- input$xaxisGrp
yv <- input$yaxisGrp
if (!is.null(xv) & !is.null(yv)){
if (sum(xv %in% names(df))>0){
mdf <- melt(df,id.vars=xv,measure.vars=yv)
gp <- ggplot(data=mdf, aes_string(x=xv,y="value")) +
geom_point()
}
}
}
return(gp)
})
}
shinyApp(ui,server)