gigla.blogg.se

Shiny rstudio tutorial
Shiny rstudio tutorial













shiny rstudio tutorial shiny rstudio tutorial

For example, the dataset includes dates so you can create a slider bar to select different dates of earthquakes to display.Shiny enables you to write powerful interactive web applications entirely in R. So we need to tell the server to update the map when the checkboxes are unchecked. If you leave this part out you will see that the checkboxes, when clicked on the first time, display our filters.But if you then uncheck them they stay on. Ui code: ui % setView(lng = -99, lat = 45, zoom = 2) %>% #setting the view over ~ center of North America addTiles() %>% addCircles(data = data, lat = ~ latitude, lng = ~ longitude, weight = 1, radius = ~sqrt(mag)*25000, popup = ~as.character(mag), label = ~as.character(paste0("Magnitude: ", sep = " ", mag)), color = ~pal(mag), fillOpacity = 0.5) }) #next we use the observe function to make the checkboxes dynamic. The tutorials on from R studio are really useful if you are not familiar with Shiny check out these tutorials (I don’t have a thorough review of Shiny so if you haven’t used Shiny before you may want to check out some in-depth tutorials before moving on): Shiny has two parts that are needed, the server and the ui code. Now that we have loaded the libraries and our data is ready, we need to build the shiny app. Let’s load the needed libraries and data #load libraries library(shiny) library(leaflet) library(dplyr) library(leaflet.extras) #import data data 70, "intermediate", ifelse(data$depth > 300, "deep", "other"))) I chose to do download data world-wide but I centered the map over North America (scroll out to see the rest of the world). You can play around with the search features to download regions and types of earthquakes you are interested in. This tutorial uses the leaflet and shiny libraries in R Shiny, let’s jump in.įirst, I downloaded earthquake data from.















Shiny rstudio tutorial