我已经创建了一个闪亮的传单地图,但我想使其具有反应性,以便仅在单击特定选项卡时才加载它。
该脚本在不响应时可以正常工作,但是现在我将其包装在响应语句中,它给了我这个错误: 错误:评估嵌套太深:无限递归/ options(expressions =)?
coronahulp <- reactive({search_tweets("coronahulp", n=1000, include_rts=FALSE, lang = 'nl', token = t)})
coronahulp2 <- reactive({coronahulp() %>% mutate(text, tolower(text)) %>%
mutate(hashtags, tolower(hashtags)) %>%
select(created_at, text, hashtags, location)})
woonplaatsen <- read_delim("Woonplaatsen_locatie.csv", delim = ";")
woonplaatsen$woonplaatsnaam <- tolower(woonplaatsen$woonplaatsnaam)
woonplaats_vector <- woonplaatsen$woonplaatsnaam
coronahulp_locatie1 <- reactive({coronahulp2() %>% select(created_at, location) %>%
mutate(location = tolower(location)) %>%
mutate(nieuw = str_extract(location, paste("\\b",woonplaats_vector,"\\b", collapse = "|", sep = ""))) %>%
filter(!(nieuw %in% c("nederland"))) %>%
filter(!(is.na(nieuw))) %>%
select(created_at, nieuw)})
coronahulp_locatie2 <- reactive({coronahulp2() %>% select(created_at, text) %>%
mutate(text = tolower(text)) %>%
mutate(nieuw = str_extract(text, paste("\\b",woonplaats_vector,"\\b", collapse = "|", sep = ""))) %>%
filter(!(nieuw %in% c("de wijk", "buren", "hoeven", "anderen", "hem", "heel","een", "zetten", "nederland", "handel", "best", "echt"))) %>%
filter(!(is.na(nieuw))) %>%
select(created_at, nieuw)})
coronahulp_locatie3 <- reactive({coronahulp2() %>% select(created_at, hashtags) %>%
mutate(hashtags = tolower(hashtags)) %>%
unnest(hashtags)%>%
mutate(nieuw = str_extract(hashtags, paste("\\b",woonplaats_vector,"\\b", collapse = "|", sep = ""))) %>%
filter(!(nieuw %in% c("de wijk", "buren", "hoeven", "anderen", "hem", "heel","een", "zetten", "nederland", "handel", "best", "echt"))) %>%
filter(!(is.na(nieuw))) %>%
select(created_at, nieuw)})
coronahulp_locatie <- reactive({rbind(coronahulp_locatie1(),coronahulp_locatie2(), coronahulp_locatie3())})
coronahulp_locatie2 <- reactive({coronahulp_locatie() %>%
unique() %>%
merge(coronahulp2) %>%
rename(woonplaatsnaam = nieuw)
})
locatie_coronahulp <- reactive({left_join(coronahulp_locatie2(), woonplaatsen) %>%
select(text, woonplaatsnaam, long, lat) %>%
unique() %>%
mutate(long = as.numeric(long), lat = as.numeric(lat)) %>%
group_by(long,lat, woonplaatsnaam) %>%
summarise(aantal = n(),text=paste(text,collapse=' <br><br> '))})
popup <- reactive({paste("<div class='leaflet-popup-scrolled' style='max-width:600px;max-height:300px'>","<b>", capitalize(locatie_coronahulp()$woonplaatsnaam),"</b>", "<br><br>",locatie_coronahulp()$text, "</div>")})
output$kaartje <- renderLeaflet({
leaflet(locatie_coronahulp()) %>%
addProviderTiles("CartoDB") %>%
addCircleMarkers(lng = ~long, lat = ~lat, label= ~capitalize(woonplaatsnaam), popup = ~popup, radius = ~aantal, stroke = FALSE, color = "#a72f6e") %>%
addResetMapButton()
})
我尝试检查是否给对象命名相同,但这似乎不是问题吗?谁能看到我所缺少的吗?
谢谢!
Jolien