Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. map("world", fill = TRUE, col = "gray36", bg = "white", xlim = input$lon_slider, ylim = input$lat_slider)
  2.  
  3. library(shiny)
  4. library(maps)
  5.  
  6. ui <- fluidPage(
  7. sidebarLayout(
  8. sidebarPanel(
  9. sliderInput("lon_slider",
  10. label = "Longitude",
  11. min = -180,
  12. max = 180,
  13. value = c(-180, 180)),
  14. sliderInput("lat_slider",
  15. label = "Latitude",
  16. min = -90,
  17. max = 90,
  18. value = c(-90, 90))),
  19. mainPanel(plotOutput("map_plot"),
  20. plotOutput("map_plot2"))
  21. )
  22. )
  23.  
  24. server <- function(input, output) {
  25.  
  26. # Creating map plot
  27. output$map_plot <- renderPlot({
  28. req(input$lon_slider)
  29. req(input$lat_slider)
  30. map("world", fill = TRUE, col = "gray36", bg = "white", xlim = input$lon_slider, ylim = input$lat_slider)
  31. title(main = "Zoom by selecting a region on this plot.")
  32. })
  33.  
  34. # Creating map plot
  35. output$map_plot2 <- renderPlot({
  36. req(input$lon_slider)
  37. req(input$lat_slider)
  38. map("world", fill = TRUE, col = "gray36", bg = "white", xlim = input$lon_slider, ylim = input$lat_slider)
  39. map("world", fill = TRUE, col = "gray36", bg = "white", xlim = input$lon_slider, ylim = input$lat_slider)
  40. title(main = "Zoom by selecting a region on this plot.")
  41. })
  42.  
  43. }
  44.  
  45. shinyApp(ui, server)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement