我希望在我的闪亮应用程序中集成传单地图。 但是,当我这样做时,我没有打印输出,并且在浏览器控制台中收到错误:
Uncaught TypeError: Cannot read property 'filter' of undefined
at exports.OutputBinding.shinyBinding.find (htmlwidgets.js:475)
at a (init_shiny.js:15)
at f (init_shiny.js:219)
at initShiny (init_shiny.js:283)
我正在使用html ui开发我的应用程序,并使用以下代码调用绘图:
{{leafletOutput("leaf1")}}
这是我的服务器。R代码:
setwd("C:/Users/Prugniaud/Google Drive/Projet R")
#Librairies
library(tidyverse)
library(ggplot2)
library(lubridate)
library(scales)
library(leaflet.extras)
library(leaflet)
library(readxl)
library(dplyr)
library(RColorBrewer)
library(gridExtra)
library(geosphere)
library(data.table)
library(shiny)
test<-as.tibble(fread("test.csv"))
train<-as.tibble(fread("train.csv"))
server <- function(input, output) {
datasetInput <- reactive({
df<-switch(input$sltDataSet,
sltTrain=test,
sltTest=train)
})
output$summary <-renderPrint(
summary(datasetInput())
)
fraction <- sample_n(as.tibble(fread("train.csv")), 10000)
pickup_longitude <- c(-73.98575)
pickup_latitude <- c(40.74856)
ville <- c('NYC')
long_lat <- data.frame(ville,pickup_longitude,pickup_latitude)
NYC<-leaflet(data = fraction) %>%
addProviderTiles("Esri.WorldImagery") %>%
setView(lng = long_lat$pickup_longitude[1],lat=long_lat$pickup_latitude[1] , zoom = 10) %>%
addCircleMarkers(lng=~pickup_longitude, lat=~pickup_latitude, radius = 1, fillOpacity = 0.3)
output$leaf1<-renderLeaflet(
NYC
)
leafletOutput("leaf1",width="1000px",heigh="1000px")
}
# Run the application
shinyApp(ui = htmlTemplate("TAXI/www/index.html"), server = server)
我做错了什么?
谢谢