闪亮的承诺不能与传单情节一起使用

时间:2020-08-20 10:29:35

标签: r shiny leaflet shinydashboard

我正在尝试使用Future and promises软件包来加快我的传单制作。我参考了 Promises package article by shiny

但是我遇到了错误。即“在使用它时不知道如何将类传单的对象转换为Promise”

library(shiny)
library(leaflet)
library(promise)
library(future)
plan(multiprocess)
library(tidyverse)

 ui <- navbarPage(
     tabPanel(
          "Map"
          , sidebarLayout(
               sidebarPanel(
                    br()
               , mainPanel(
                     leafletOutput("plot_map")
))))

#Loading Germany map using future
shp1 <- future({geojson_read('www/bundeslander.geojson', what="sp")})
geo_lookup <- read.csv('www/country_codes.csv', stringsAsFactors=F)

server <- function(input, output, session)
{
  facebook_filtered <- reactive({
    data_fb %>%
      collect() %>%
      mutate_if(is.integer64, as.integer) %>%
      left_join(geo_lookup, by=c("country_name"="Code"))
    
  })
  map_data <- reactive({
        fbf <- facebook_filtered()

 shp1@data %...>%
          mutate_if(is.factor, as.character) %...>%
          left_join(fbf %...>%
                      mutate(region=as.character(region)) %...>%
                      group_by(region) %...>%
                      summarise(impressions_total = sum(impressions, na.rm=T)) %...>%
                      # and then we use these column names to select which data we want to map in the
                      # utility function
                      rename("impressions"=impressions_total) %...>% rename('video_views'=video_views_total),
                    by=c("name"="region")) %...>%
          replace(is.na(.), 0)

})

build_leaflet_map <- function(shape_data) {

    leaflet(data= shp1) %...>%
      addProviderTiles(providers$CartoDB.Positron) %...>%
      addPolygons(
        stroke=T,
        color="#c2c5cc",
        weight=1,
        opacity=1,
        fillOpacity=1,
        fillColor =  if(sum(shape_data[[data_column]]) > 0) { ~ pal(shape_data[[data_column]]) } else { "#ffffff" },
        highlight = highlightOptions(
          weight = 2,
          color = "#989898",
          fillOpacity = 0.9,
          bringToFront = T
        ),
        label = sprintf( ## TODO - Tidy this up
          paste0(
            "<strong>%s</strong><br/>%s ",
            gsub('_', ' ', i18n()$t(data_column))
          ),
          str_to_title(shape_data$name), ## TODO - Set locale to DE where client language is German
          num_format(shape_data[[data_column]])
        ) %...>% lapply(HTML),
        labelOptions = labelOptions(
          style = list("font-weight" = "normal", padding = "5px 10px"),
          textsize = "15px",
          direction = "auto"
        )
      )

    
  }
  #=========================
  
  output$plot_map <- renderLeaflet({
    build_leaflet_map(map_data())
  })



}

# Return a Shiny app object
shinyApp(ui = ui, server = server, options = list(port = 4600, host = '0.0.0.0'))
 

我还没有看到将传单承诺

结合使用的任何来源

任何人都可以解决的问题真的很有帮助

0 个答案:

没有答案