clearMarkers() %>% clearShapes() %>% causing RStudio to CrashRStudio Shiny Conditional PlotUpdate R using RStudioFunction to clear the console in R and RStudioScale and size of plot in RStudio shinyLeaflet drill down with RStudio package and Shinyshiny causes RStudio to crashSort legend (for colorFactor) using leaflet package (RStudio) in Shiny AppShiny app crashes on Mac in RStudioShiny app crash, issue with leaflet Shiny RStudioRStudio Shiny app crashes

The use of multiple foreign keys on same column in SQL Server

Why was the small council so happy for Tyrion to become the Master of Coin?

How can bays and straits be determined in a procedurally generated map?

How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?

Why are 150k or 200k jobs considered good when there are 300k+ births a month?

Show that if two triangles built on parallel lines, with equal bases have the same perimeter only if they are congruent.

Why don't electron-positron collisions release infinite energy?

Why dont electromagnetic waves interact with each other?

What do you call a Matrix-like slowdown and camera movement effect?

Which models of the Boeing 737 are still in production?

What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)

Why can't I see bouncing of a switch on an oscilloscope?

Can divisibility rules for digits be generalized to sum of digits

How old can references or sources in a thesis be?

Writing rule stating superpower from different root cause is bad writing

What is the word for reserving something for yourself before others do?

Windows 98 hangs after entering password on fresh install

Has the BBC provided arguments for saying Brexit being cancelled is unlikely?

In Japanese, what’s the difference between “Tonari ni” (となりに) and “Tsugi” (つぎ)? When would you use one over the other?

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

Is a tag line useful on a cover?

Why do I get two different answers for this counting problem?

Do I have a twin with permutated remainders?

How is it possible to have an ability score that is less than 3?



clearMarkers() %>% clearShapes() %>% causing RStudio to Crash


RStudio Shiny Conditional PlotUpdate R using RStudioFunction to clear the console in R and RStudioScale and size of plot in RStudio shinyLeaflet drill down with RStudio package and Shinyshiny causes RStudio to crashSort legend (for colorFactor) using leaflet package (RStudio) in Shiny AppShiny app crashes on Mac in RStudioShiny app crash, issue with leaflet Shiny RStudioRStudio Shiny app crashes






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I've built a Shiny App with Leaflet that for the most part works. However, "clearMarkers() %>% clearShapes() %>%" seems to be causing my RStudio to crash. When I switch these off, my application no longer crashes. However, the map doesn't clear. Has anyone been able to solve this issue for themselves? I need to be able to clear the map each time an input is changed. I appreciate the help.



library(shiny)
library(leaflet)
library(dplyr)
library(rgdal)
library(RColorBrewer)
library(colorRamps)
library(sf)
library(data.table)

monthStart <- function(x)
x <- as.POSIXlt(x)
x$mday <- 1
as.Date(x)


# Define UI for application
ui <- fluidPage(
#Input Station Drop Down
selectizeInput("Selectedstation", "Select Station",
stationfinal$Var1, selected = "3000 Connecticut Ave NW / National Zoo", multiple = FALSE,
options = NULL),


#Insert Slider
sliderInput("YearMonth", "Date of Bikeshare",min(as.Date("2018-01-01")),
max(as.Date("2018-12-01")),
value = max(as.Date("2018-12-01")),
timeFormat="%b %Y",
step=1,
animate=animationOptions(interval=1,loop=FALSE,playButton = "Play Animiation")),


#Insert Radio Button - Origin vs. Destination
radioButtons("Direction", "Review Trips That",
c("Start At Selected Station" = "OriginTrips",
"End At Selected Station" = "DestinationTrips")),

#Insert Radio Button - Aggregate By
radioButtons("DisplayBy", "Display by:",
c("Monthly Usage" = "MonUse",
"Total Usage" = "TotUse")),


#Insert Map
leafletOutput("mymap",width="800px", height="800px")

)



# Define server logic required to draw a histogram
server <- function(input, output, session)

sliderMonth <- reactiveValues()


observe(
full.date <- as.Date(input$YearMonth)
sliderMonth$Month <- as.character(monthStart(full.date))

)


points.all <- reactive(if(input$Direction == "OriginTrips")
Bikeshare_Data_Aggreggated2[ which(Bikeshare_Data_Aggreggated2$Start.station == input$Selectedstation &
Bikeshare_Data_Aggreggated2$FixedDate == sliderMonth$Month &
!is.na(Bikeshare_Data_Aggreggated2$lon.dest)) ,]


else
Bikeshare_Data_Aggreggated2[ which(Bikeshare_Data_Aggreggated2$End.station == input$Selectedstation &
Bikeshare_Data_Aggreggated2$FixedDate == sliderMonth$Month &
!is.na(Bikeshare_Data_Aggreggated2$lon.org)) ,]


)




output$mymap <- renderLeaflet(
leaflet() %>% addTiles() %>% setView(lng = -76.99, lat = 38.93, zoom = 12)

)




observe(
#prepare point data
if(input$DisplayBy == "TotUse")
display.points<-points.all()[points.all()$CumTrips>0,]
display.points$Trips<-display.points$CumTrips
display.points$Radius<-sqrt(display.points$CumTrips)
if(input$DisplayBy == "MonUse")
display.points<-points.all()[points.all()$Trips>0,]
display.points$Trips<-display.points$Trips
display.points$Radius<-display.points$Trips

if(input$Direction == "OriginTrips")
display.points$lon<-display.points$lon.dest
display.points$lat<-display.points$lat.dest
DisplayLon<-unique(display.points$lon.org)
DisplayLat<-unique(display.points$lat.org)
display.points$Station<-display.points$End.station
if(input$Direction == "DestinationTrips")
display.points$lon<-display.points$lon.org
display.points$lat<-display.points$lat.org
DisplayLon<-unique(display.points$lon.dest)
DisplayLat<-unique(display.points$lat.dest)
display.points$Station<-display.points$Start.station

#prepare heatmap data
Bikeshare_sf = st_as_sf(display.points, coords = c("lon", "lat"), crs = 4269, agr = "constant")
All_States_Joined<-st_join(AllStates,Bikeshare_sf) %>%
group_by(GEOID, NAMELSAD) %>%
summarise(stations = n(),
Trips = sum(Trips)) %>%
mutate(stations = ifelse(is.na(Trips),0,stations))

heatmap_labels<-paste0("<strong>Census Tract: </strong>",
All_States_Joined$NAMELSAD,
"<br><strong>Stations in CT: </strong>",
All_States_Joined$stations,
"<br><strong>Number of Trips: </strong>",
All_States_Joined$Trips) %>% lapply(htmltools::HTML)



#Show Aggregated TRips
CircleColors<-colorQuantile(colorRamp(c("#008000", "#FF0000"), interpolate="spline"), unique(display.points$Trips), n = 5)
leafletProxy("mymap", data = display.points ) %>%
clearMarkers() %>% clearShapes() %>%

addCircleMarkers(data = display.points, group = "Circles",
lng = display.points$lon,
lat = display.points$lat,
radius = display.points$Radius,
popup = paste0("<strong>Station Name: </strong>",
display.points$Station,
"<br><strong>Number of Trips: </strong>",
display.points$Trips),
color = CircleColors(display.points$Trips),
stroke = TRUE) %>% flyTo(DisplayLon ,DisplayLat, 13) %>%

addPolygons(data = All_States_Joined, group = "Polygons",
color = "#444444", weight = 1, smoothFactor = 0.5,
opacity = 1.0, fillOpacity = 0.5,
fillColor = ~colorBin("YlOrRd", Trips)(Trips),
highlightOptions = highlightOptions(color = "white", weight = 2,
bringToFront = TRUE),
label = heatmap_labels,
labelOptions = labelOptions(style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto")) %>%

addMarkers(data = display.points,
group = "Stations",
lng = display.points$lon,
lat = display.points$lat,
options = markerOptions(riseOnHover = TRUE),
popup = paste0("<strong>Station Name: </strong>",
display.points$Station,
"<br><strong>Number of Trips: </strong>",
display.points$Trips)) %>% hideGroup("Stations") %>%
addLayersControl(
baseGroups = c("Circles", "Polygons"),
overlayGroups = c("Stations"),

options = layersControlOptions(collapsed = FALSE))






)





# Run the application
shinyApp(ui, server)









share|improve this question

















  • 2





    Try to create a SSCCE: Short, Self Contained, Correct (Compilable), Example for questions.

    – user2864740
    Mar 9 at 3:38


















-1















I've built a Shiny App with Leaflet that for the most part works. However, "clearMarkers() %>% clearShapes() %>%" seems to be causing my RStudio to crash. When I switch these off, my application no longer crashes. However, the map doesn't clear. Has anyone been able to solve this issue for themselves? I need to be able to clear the map each time an input is changed. I appreciate the help.



library(shiny)
library(leaflet)
library(dplyr)
library(rgdal)
library(RColorBrewer)
library(colorRamps)
library(sf)
library(data.table)

monthStart <- function(x)
x <- as.POSIXlt(x)
x$mday <- 1
as.Date(x)


# Define UI for application
ui <- fluidPage(
#Input Station Drop Down
selectizeInput("Selectedstation", "Select Station",
stationfinal$Var1, selected = "3000 Connecticut Ave NW / National Zoo", multiple = FALSE,
options = NULL),


#Insert Slider
sliderInput("YearMonth", "Date of Bikeshare",min(as.Date("2018-01-01")),
max(as.Date("2018-12-01")),
value = max(as.Date("2018-12-01")),
timeFormat="%b %Y",
step=1,
animate=animationOptions(interval=1,loop=FALSE,playButton = "Play Animiation")),


#Insert Radio Button - Origin vs. Destination
radioButtons("Direction", "Review Trips That",
c("Start At Selected Station" = "OriginTrips",
"End At Selected Station" = "DestinationTrips")),

#Insert Radio Button - Aggregate By
radioButtons("DisplayBy", "Display by:",
c("Monthly Usage" = "MonUse",
"Total Usage" = "TotUse")),


#Insert Map
leafletOutput("mymap",width="800px", height="800px")

)



# Define server logic required to draw a histogram
server <- function(input, output, session)

sliderMonth <- reactiveValues()


observe(
full.date <- as.Date(input$YearMonth)
sliderMonth$Month <- as.character(monthStart(full.date))

)


points.all <- reactive(if(input$Direction == "OriginTrips")
Bikeshare_Data_Aggreggated2[ which(Bikeshare_Data_Aggreggated2$Start.station == input$Selectedstation &
Bikeshare_Data_Aggreggated2$FixedDate == sliderMonth$Month &
!is.na(Bikeshare_Data_Aggreggated2$lon.dest)) ,]


else
Bikeshare_Data_Aggreggated2[ which(Bikeshare_Data_Aggreggated2$End.station == input$Selectedstation &
Bikeshare_Data_Aggreggated2$FixedDate == sliderMonth$Month &
!is.na(Bikeshare_Data_Aggreggated2$lon.org)) ,]


)




output$mymap <- renderLeaflet(
leaflet() %>% addTiles() %>% setView(lng = -76.99, lat = 38.93, zoom = 12)

)




observe(
#prepare point data
if(input$DisplayBy == "TotUse")
display.points<-points.all()[points.all()$CumTrips>0,]
display.points$Trips<-display.points$CumTrips
display.points$Radius<-sqrt(display.points$CumTrips)
if(input$DisplayBy == "MonUse")
display.points<-points.all()[points.all()$Trips>0,]
display.points$Trips<-display.points$Trips
display.points$Radius<-display.points$Trips

if(input$Direction == "OriginTrips")
display.points$lon<-display.points$lon.dest
display.points$lat<-display.points$lat.dest
DisplayLon<-unique(display.points$lon.org)
DisplayLat<-unique(display.points$lat.org)
display.points$Station<-display.points$End.station
if(input$Direction == "DestinationTrips")
display.points$lon<-display.points$lon.org
display.points$lat<-display.points$lat.org
DisplayLon<-unique(display.points$lon.dest)
DisplayLat<-unique(display.points$lat.dest)
display.points$Station<-display.points$Start.station

#prepare heatmap data
Bikeshare_sf = st_as_sf(display.points, coords = c("lon", "lat"), crs = 4269, agr = "constant")
All_States_Joined<-st_join(AllStates,Bikeshare_sf) %>%
group_by(GEOID, NAMELSAD) %>%
summarise(stations = n(),
Trips = sum(Trips)) %>%
mutate(stations = ifelse(is.na(Trips),0,stations))

heatmap_labels<-paste0("<strong>Census Tract: </strong>",
All_States_Joined$NAMELSAD,
"<br><strong>Stations in CT: </strong>",
All_States_Joined$stations,
"<br><strong>Number of Trips: </strong>",
All_States_Joined$Trips) %>% lapply(htmltools::HTML)



#Show Aggregated TRips
CircleColors<-colorQuantile(colorRamp(c("#008000", "#FF0000"), interpolate="spline"), unique(display.points$Trips), n = 5)
leafletProxy("mymap", data = display.points ) %>%
clearMarkers() %>% clearShapes() %>%

addCircleMarkers(data = display.points, group = "Circles",
lng = display.points$lon,
lat = display.points$lat,
radius = display.points$Radius,
popup = paste0("<strong>Station Name: </strong>",
display.points$Station,
"<br><strong>Number of Trips: </strong>",
display.points$Trips),
color = CircleColors(display.points$Trips),
stroke = TRUE) %>% flyTo(DisplayLon ,DisplayLat, 13) %>%

addPolygons(data = All_States_Joined, group = "Polygons",
color = "#444444", weight = 1, smoothFactor = 0.5,
opacity = 1.0, fillOpacity = 0.5,
fillColor = ~colorBin("YlOrRd", Trips)(Trips),
highlightOptions = highlightOptions(color = "white", weight = 2,
bringToFront = TRUE),
label = heatmap_labels,
labelOptions = labelOptions(style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto")) %>%

addMarkers(data = display.points,
group = "Stations",
lng = display.points$lon,
lat = display.points$lat,
options = markerOptions(riseOnHover = TRUE),
popup = paste0("<strong>Station Name: </strong>",
display.points$Station,
"<br><strong>Number of Trips: </strong>",
display.points$Trips)) %>% hideGroup("Stations") %>%
addLayersControl(
baseGroups = c("Circles", "Polygons"),
overlayGroups = c("Stations"),

options = layersControlOptions(collapsed = FALSE))






)





# Run the application
shinyApp(ui, server)









share|improve this question

















  • 2





    Try to create a SSCCE: Short, Self Contained, Correct (Compilable), Example for questions.

    – user2864740
    Mar 9 at 3:38














-1












-1








-1








I've built a Shiny App with Leaflet that for the most part works. However, "clearMarkers() %>% clearShapes() %>%" seems to be causing my RStudio to crash. When I switch these off, my application no longer crashes. However, the map doesn't clear. Has anyone been able to solve this issue for themselves? I need to be able to clear the map each time an input is changed. I appreciate the help.



library(shiny)
library(leaflet)
library(dplyr)
library(rgdal)
library(RColorBrewer)
library(colorRamps)
library(sf)
library(data.table)

monthStart <- function(x)
x <- as.POSIXlt(x)
x$mday <- 1
as.Date(x)


# Define UI for application
ui <- fluidPage(
#Input Station Drop Down
selectizeInput("Selectedstation", "Select Station",
stationfinal$Var1, selected = "3000 Connecticut Ave NW / National Zoo", multiple = FALSE,
options = NULL),


#Insert Slider
sliderInput("YearMonth", "Date of Bikeshare",min(as.Date("2018-01-01")),
max(as.Date("2018-12-01")),
value = max(as.Date("2018-12-01")),
timeFormat="%b %Y",
step=1,
animate=animationOptions(interval=1,loop=FALSE,playButton = "Play Animiation")),


#Insert Radio Button - Origin vs. Destination
radioButtons("Direction", "Review Trips That",
c("Start At Selected Station" = "OriginTrips",
"End At Selected Station" = "DestinationTrips")),

#Insert Radio Button - Aggregate By
radioButtons("DisplayBy", "Display by:",
c("Monthly Usage" = "MonUse",
"Total Usage" = "TotUse")),


#Insert Map
leafletOutput("mymap",width="800px", height="800px")

)



# Define server logic required to draw a histogram
server <- function(input, output, session)

sliderMonth <- reactiveValues()


observe(
full.date <- as.Date(input$YearMonth)
sliderMonth$Month <- as.character(monthStart(full.date))

)


points.all <- reactive(if(input$Direction == "OriginTrips")
Bikeshare_Data_Aggreggated2[ which(Bikeshare_Data_Aggreggated2$Start.station == input$Selectedstation &
Bikeshare_Data_Aggreggated2$FixedDate == sliderMonth$Month &
!is.na(Bikeshare_Data_Aggreggated2$lon.dest)) ,]


else
Bikeshare_Data_Aggreggated2[ which(Bikeshare_Data_Aggreggated2$End.station == input$Selectedstation &
Bikeshare_Data_Aggreggated2$FixedDate == sliderMonth$Month &
!is.na(Bikeshare_Data_Aggreggated2$lon.org)) ,]


)




output$mymap <- renderLeaflet(
leaflet() %>% addTiles() %>% setView(lng = -76.99, lat = 38.93, zoom = 12)

)




observe(
#prepare point data
if(input$DisplayBy == "TotUse")
display.points<-points.all()[points.all()$CumTrips>0,]
display.points$Trips<-display.points$CumTrips
display.points$Radius<-sqrt(display.points$CumTrips)
if(input$DisplayBy == "MonUse")
display.points<-points.all()[points.all()$Trips>0,]
display.points$Trips<-display.points$Trips
display.points$Radius<-display.points$Trips

if(input$Direction == "OriginTrips")
display.points$lon<-display.points$lon.dest
display.points$lat<-display.points$lat.dest
DisplayLon<-unique(display.points$lon.org)
DisplayLat<-unique(display.points$lat.org)
display.points$Station<-display.points$End.station
if(input$Direction == "DestinationTrips")
display.points$lon<-display.points$lon.org
display.points$lat<-display.points$lat.org
DisplayLon<-unique(display.points$lon.dest)
DisplayLat<-unique(display.points$lat.dest)
display.points$Station<-display.points$Start.station

#prepare heatmap data
Bikeshare_sf = st_as_sf(display.points, coords = c("lon", "lat"), crs = 4269, agr = "constant")
All_States_Joined<-st_join(AllStates,Bikeshare_sf) %>%
group_by(GEOID, NAMELSAD) %>%
summarise(stations = n(),
Trips = sum(Trips)) %>%
mutate(stations = ifelse(is.na(Trips),0,stations))

heatmap_labels<-paste0("<strong>Census Tract: </strong>",
All_States_Joined$NAMELSAD,
"<br><strong>Stations in CT: </strong>",
All_States_Joined$stations,
"<br><strong>Number of Trips: </strong>",
All_States_Joined$Trips) %>% lapply(htmltools::HTML)



#Show Aggregated TRips
CircleColors<-colorQuantile(colorRamp(c("#008000", "#FF0000"), interpolate="spline"), unique(display.points$Trips), n = 5)
leafletProxy("mymap", data = display.points ) %>%
clearMarkers() %>% clearShapes() %>%

addCircleMarkers(data = display.points, group = "Circles",
lng = display.points$lon,
lat = display.points$lat,
radius = display.points$Radius,
popup = paste0("<strong>Station Name: </strong>",
display.points$Station,
"<br><strong>Number of Trips: </strong>",
display.points$Trips),
color = CircleColors(display.points$Trips),
stroke = TRUE) %>% flyTo(DisplayLon ,DisplayLat, 13) %>%

addPolygons(data = All_States_Joined, group = "Polygons",
color = "#444444", weight = 1, smoothFactor = 0.5,
opacity = 1.0, fillOpacity = 0.5,
fillColor = ~colorBin("YlOrRd", Trips)(Trips),
highlightOptions = highlightOptions(color = "white", weight = 2,
bringToFront = TRUE),
label = heatmap_labels,
labelOptions = labelOptions(style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto")) %>%

addMarkers(data = display.points,
group = "Stations",
lng = display.points$lon,
lat = display.points$lat,
options = markerOptions(riseOnHover = TRUE),
popup = paste0("<strong>Station Name: </strong>",
display.points$Station,
"<br><strong>Number of Trips: </strong>",
display.points$Trips)) %>% hideGroup("Stations") %>%
addLayersControl(
baseGroups = c("Circles", "Polygons"),
overlayGroups = c("Stations"),

options = layersControlOptions(collapsed = FALSE))






)





# Run the application
shinyApp(ui, server)









share|improve this question














I've built a Shiny App with Leaflet that for the most part works. However, "clearMarkers() %>% clearShapes() %>%" seems to be causing my RStudio to crash. When I switch these off, my application no longer crashes. However, the map doesn't clear. Has anyone been able to solve this issue for themselves? I need to be able to clear the map each time an input is changed. I appreciate the help.



library(shiny)
library(leaflet)
library(dplyr)
library(rgdal)
library(RColorBrewer)
library(colorRamps)
library(sf)
library(data.table)

monthStart <- function(x)
x <- as.POSIXlt(x)
x$mday <- 1
as.Date(x)


# Define UI for application
ui <- fluidPage(
#Input Station Drop Down
selectizeInput("Selectedstation", "Select Station",
stationfinal$Var1, selected = "3000 Connecticut Ave NW / National Zoo", multiple = FALSE,
options = NULL),


#Insert Slider
sliderInput("YearMonth", "Date of Bikeshare",min(as.Date("2018-01-01")),
max(as.Date("2018-12-01")),
value = max(as.Date("2018-12-01")),
timeFormat="%b %Y",
step=1,
animate=animationOptions(interval=1,loop=FALSE,playButton = "Play Animiation")),


#Insert Radio Button - Origin vs. Destination
radioButtons("Direction", "Review Trips That",
c("Start At Selected Station" = "OriginTrips",
"End At Selected Station" = "DestinationTrips")),

#Insert Radio Button - Aggregate By
radioButtons("DisplayBy", "Display by:",
c("Monthly Usage" = "MonUse",
"Total Usage" = "TotUse")),


#Insert Map
leafletOutput("mymap",width="800px", height="800px")

)



# Define server logic required to draw a histogram
server <- function(input, output, session)

sliderMonth <- reactiveValues()


observe(
full.date <- as.Date(input$YearMonth)
sliderMonth$Month <- as.character(monthStart(full.date))

)


points.all <- reactive(if(input$Direction == "OriginTrips")
Bikeshare_Data_Aggreggated2[ which(Bikeshare_Data_Aggreggated2$Start.station == input$Selectedstation &
Bikeshare_Data_Aggreggated2$FixedDate == sliderMonth$Month &
!is.na(Bikeshare_Data_Aggreggated2$lon.dest)) ,]


else
Bikeshare_Data_Aggreggated2[ which(Bikeshare_Data_Aggreggated2$End.station == input$Selectedstation &
Bikeshare_Data_Aggreggated2$FixedDate == sliderMonth$Month &
!is.na(Bikeshare_Data_Aggreggated2$lon.org)) ,]


)




output$mymap <- renderLeaflet(
leaflet() %>% addTiles() %>% setView(lng = -76.99, lat = 38.93, zoom = 12)

)




observe(
#prepare point data
if(input$DisplayBy == "TotUse")
display.points<-points.all()[points.all()$CumTrips>0,]
display.points$Trips<-display.points$CumTrips
display.points$Radius<-sqrt(display.points$CumTrips)
if(input$DisplayBy == "MonUse")
display.points<-points.all()[points.all()$Trips>0,]
display.points$Trips<-display.points$Trips
display.points$Radius<-display.points$Trips

if(input$Direction == "OriginTrips")
display.points$lon<-display.points$lon.dest
display.points$lat<-display.points$lat.dest
DisplayLon<-unique(display.points$lon.org)
DisplayLat<-unique(display.points$lat.org)
display.points$Station<-display.points$End.station
if(input$Direction == "DestinationTrips")
display.points$lon<-display.points$lon.org
display.points$lat<-display.points$lat.org
DisplayLon<-unique(display.points$lon.dest)
DisplayLat<-unique(display.points$lat.dest)
display.points$Station<-display.points$Start.station

#prepare heatmap data
Bikeshare_sf = st_as_sf(display.points, coords = c("lon", "lat"), crs = 4269, agr = "constant")
All_States_Joined<-st_join(AllStates,Bikeshare_sf) %>%
group_by(GEOID, NAMELSAD) %>%
summarise(stations = n(),
Trips = sum(Trips)) %>%
mutate(stations = ifelse(is.na(Trips),0,stations))

heatmap_labels<-paste0("<strong>Census Tract: </strong>",
All_States_Joined$NAMELSAD,
"<br><strong>Stations in CT: </strong>",
All_States_Joined$stations,
"<br><strong>Number of Trips: </strong>",
All_States_Joined$Trips) %>% lapply(htmltools::HTML)



#Show Aggregated TRips
CircleColors<-colorQuantile(colorRamp(c("#008000", "#FF0000"), interpolate="spline"), unique(display.points$Trips), n = 5)
leafletProxy("mymap", data = display.points ) %>%
clearMarkers() %>% clearShapes() %>%

addCircleMarkers(data = display.points, group = "Circles",
lng = display.points$lon,
lat = display.points$lat,
radius = display.points$Radius,
popup = paste0("<strong>Station Name: </strong>",
display.points$Station,
"<br><strong>Number of Trips: </strong>",
display.points$Trips),
color = CircleColors(display.points$Trips),
stroke = TRUE) %>% flyTo(DisplayLon ,DisplayLat, 13) %>%

addPolygons(data = All_States_Joined, group = "Polygons",
color = "#444444", weight = 1, smoothFactor = 0.5,
opacity = 1.0, fillOpacity = 0.5,
fillColor = ~colorBin("YlOrRd", Trips)(Trips),
highlightOptions = highlightOptions(color = "white", weight = 2,
bringToFront = TRUE),
label = heatmap_labels,
labelOptions = labelOptions(style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto")) %>%

addMarkers(data = display.points,
group = "Stations",
lng = display.points$lon,
lat = display.points$lat,
options = markerOptions(riseOnHover = TRUE),
popup = paste0("<strong>Station Name: </strong>",
display.points$Station,
"<br><strong>Number of Trips: </strong>",
display.points$Trips)) %>% hideGroup("Stations") %>%
addLayersControl(
baseGroups = c("Circles", "Polygons"),
overlayGroups = c("Stations"),

options = layersControlOptions(collapsed = FALSE))






)





# Run the application
shinyApp(ui, server)






r shiny leaflet rstudio






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 9 at 2:36









Federico TallisFederico Tallis

11




11







  • 2





    Try to create a SSCCE: Short, Self Contained, Correct (Compilable), Example for questions.

    – user2864740
    Mar 9 at 3:38













  • 2





    Try to create a SSCCE: Short, Self Contained, Correct (Compilable), Example for questions.

    – user2864740
    Mar 9 at 3:38








2




2





Try to create a SSCCE: Short, Self Contained, Correct (Compilable), Example for questions.

– user2864740
Mar 9 at 3:38






Try to create a SSCCE: Short, Self Contained, Correct (Compilable), Example for questions.

– user2864740
Mar 9 at 3:38













0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073474%2fclearmarkers-clearshapes-causing-rstudio-to-crash%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073474%2fclearmarkers-clearshapes-causing-rstudio-to-crash%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme