R Shinny:在我的Shinny应用程序中使用大型空间多边形框架

R Shinny:在我的Shinny应用程序中使用大型空间多边形框架,r,shiny,R,Shiny,我正试图在我闪亮的传单应用程序中使用我准备好的大空间多边形框架。我不明白的是如何在我的服务器中使用我的大空间多边形数据框。当我运行load_data.R脚本,然后运行server.R脚本时,这个闪亮的应用程序运行得非常好。我的问题是: 如果不单独运行load_data.R,而只运行server.R,如何让闪亮的应用程序工作 加载\u数据。R: 服务器.R: 用户界面 提前谢谢 Yoorizz启动闪亮应用程序时,它只查找server.R和ui.R。请参见?闪亮::runApp。因此,load_da

我正试图在我闪亮的传单应用程序中使用我准备好的大空间多边形框架。我不明白的是如何在我的服务器中使用我的大空间多边形数据框。当我运行load_data.R脚本,然后运行server.R脚本时,这个闪亮的应用程序运行得非常好。我的问题是:

如果不单独运行load_data.R,而只运行server.R,如何让闪亮的应用程序工作

加载\u数据。R:

服务器.R:

用户界面

提前谢谢


Yoorizz

启动闪亮应用程序时,它只查找server.R和ui.R。请参见?闪亮::runApp。因此,load_data.R不是来源


尝试将sourceload_data.R添加到server.R.

谢谢您的输入。我已经试过了,结果是:filefilename中的警告,r,encoding=encoding:无法打开文件'load_data.r':没有这样的文件或目录警告:文件中的错误:无法首先打开最里面的连接堆栈跟踪:41:file 40:source 1:Shining::runApp文件名中的错误,r,encoding=encoding:无法打开连接…当我在server.R中选择sourceload_data.R时,它会工作。当我按下“运行应用程序”按钮时出现错误。您的工作目录可能错误。使用getwd以交互方式检查它。启动应用程序时,请确保load_data.R位于同一目录中,或者指定到它的正确相对路径。getwd表示我在T:/GitHub/shinny server/NL_
    library(RSQLite)
    library(rgdal)
    library(dplyr)

    # Use the SQLite database
    my_sqdb = src_sqlite("NL_Household_Penetration/Data/dataset.sqlite")

    # Extract the main dataset out of the SQLite database
    df = data.frame(tbl(my_sqdb, sql("SELECT * FROM df")))

    # Extract the stores with their locations out of the SQLite database
    Winkels = data.frame(tbl(my_sqdb, sql("SELECT * FROM Winkels")))

    # Read the shape-data(polygons) into R
    shape <-readOGR("NL_Household_Penetration/PMA_Shape/Polygonen NL Postcodes 4PP.kml", "Polygonen NL Postcodes 4PP")

    # Combine the main dataset with the shape data to plot data into zipcode areas
    SalesMap <- merge(shape, df, by.x='Description', by.y='POSTCODE')
#shiny
library(shiny)
library(shinydashboard)

#define color
library(RColorBrewer)
library(colorspace)

# leaflet map
library(leaflet)
library(htmlwidgets)
library(htmltools)


## Creating leaflet map
pal <- colorNumeric("Reds",SalesMap@data$SALES)

polygon_popup <- paste0("<strong>Postcode: </strong>", SalesMap$Description, "<br>",
                        "<strong>Waarden: </strong>", SalesMap$SALES)

pop = as.character(Winkels$WINKEL)

Icon <- makeIcon(
  iconUrl = "NL_Household_Penetration/Images/image.png",
  iconWidth = 100, iconHeight = 78
)

server <- function(input, output, session) {

  output$mymap <- renderLeaflet({

    leaflet() %>% 
      addTiles(
        urlTemplate = "//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png",
        attribution = 'Maps by <a href="http://www.mapbox.com/">Mapbox</a>'
      )  %>%


      addPolygons(data = SalesMap,
                  fillColor = ~pal(SalesMap@data$SALES),         
                  fillOpacity = 0.6,  ## how transparent do you want the polygon to be? 
                  popup = polygon_popup,
                  color = "black",       ## color of borders between districts
                  weight = 2.0) %>%

      addMarkers(Winkels$Lon, Winkels$Lat, popup=pop, icon=IKEAIcon)

  })
}
 library(shiny)
 library(shinydashboard)
 library(leaflet)


    ui <- bootstrapPage(
      tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
      leafletOutput("mymap", width = "100%", height = "100%")
    )