R shiny Leaflet错误:addMarkers没有从反应函数

时间:2017-04-26 15:37:49

标签: r shiny leaflet

我正在尝试在Shiny中创建一个Leaflet,它根据许多参数过滤数据集,并仅绘制用户选择的那些点。一切都有效,除了一个关键部分:当我运行应用程序时,我得到"错误:未找到点数据;请为addMarkers提供数据和/或lng / lat参数"信息。 编辑:即使input$question1 == FALSE我也收到此错误。这对我来说很有意义,因为我没有为绘图定义else或初始数据集,但它可能是相关的。

以下是dput的{​​{1}}部分:

dataset

以下是我用来生成过滤值和renderLeaflet代码的反应函数:

dput(dataset[1:10,14:24]) 
structure(list(target.pops = structure(c(6L, 
6L, 18L, 31L, 21L, 27L, 27L, 18L, 6L, 27L), .Label = c("DD Adult", 
"DD Adult, DD Child", "DD Adult, DD Child, MH Adult", "DD Adult, DD Child, 
MH Adult, MH Child", 
"DD Adult, DD Child, MH Adult, MH Child, SA Adult", "DD Adult, DD Child, MH 
Adult, MH Child, SA Adult, SA Child", 
"DD Adult, DD Child, MH Adult, MH Child, SA Child", "DD Adult, DD Child, MH 
Child", 
"DD Adult, MH Adult", "DD Adult, MH Adult, MH Child", "DD Adult, MH Adult, 
MH Child, SA Adult", 
"DD Adult, MH Adult, MH Child, SA Adult, SA Child", "DD Adult, MH Adult, SA 
Adult", 
"DD Adult, MH Child", "DD Child, MH Adult, MH Child", "DD Child, MH Adult, 
MH Child, SA Child", 
"DD Child, MH Child", "DD Child, MH Child, SA Child", "DD Child, SA Child", 
"MH Adult", "MH Adult, MH Child", "MH Adult, MH Child, SA Adult", 
"MH Adult, MH Child, SA Adult, SA Child", "MH Adult, MH Child, SA Child", 
"MH Adult, SA Adult", "MH Adult, SA Adult, SA Child", "MH Child", 
"MH Child, SA Adult", "MH Child, SA Child", "SA Adult", "Unknown"
), class = "factor"), 
col.data = c(1L, 1L, 1L, 9L, 1L, 1L, 1L, 
1L, 1L, 1L), 
adult = c(1L, 1L, 0L, 9L, 1L, 0L, 0L, 0L, 1L, 
0L), dd = c(1L, 1L, 1L, 9L, 0L, 0L, 0L, 1L, 1L, 0L), mh = c(1L, 
1L, 1L, 9L, 1L, 1L, 1L, 1L, 1L, 1L),
sa = c(1L, 1L, 1L, 9L, 
0L, 0L, 0L, 1L, 1L, 0L), 
outpt = c(0L, 0L, 0L, 0L, 1L, 0L, 
1L, 0L, 0L, 0L), iw = c(1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 
0L), b3 = c(0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L)),
.Names = c("status", "service", "target.pops", "child", "adult", "dd", "mh", 
"sa", "outpt", "iw", "b3"), row.names = c(NA, 10L), class = "data.frame")

任何想法出了什么问题?提前感谢任何见解!

1 个答案:

答案 0 :(得分:0)

我能解决这个问题。卡住一周后,我将addMarkers语法更改为

addMarkers(data = points())

它按预期工作。