R 错误:Shinyapps.io的textOutput中的“times”参数无效
我对R和Shinyapps有一个很奇怪的问题。问题是,当我在RStudio中运行应用程序时,一切正常,但当我在Shinyapps.io上发布它时,我在一些textOutput对象上遇到以下错误: 错误:无效的“times”参数 这对我来说毫无意义,但嘿,这可能是有原因的 我在这里分享我的完整代码。这是一个使用R上的ggmap、dplyr和shinyapp库的中间计算器 对于ui.R文件,我有:R 错误:Shinyapps.io的textOutput中的“times”参数无效,r,shiny,shiny-server,ggmap,R,Shiny,Shiny Server,Ggmap,我对R和Shinyapps有一个很奇怪的问题。问题是,当我在RStudio中运行应用程序时,一切正常,但当我在Shinyapps.io上发布它时,我在一些textOutput对象上遇到以下错误: 错误:无效的“times”参数 这对我来说毫无意义,但嘿,这可能是有原因的 我在这里分享我的完整代码。这是一个使用R上的ggmap、dplyr和shinyapp库的中间计算器 对于ui.R文件,我有: library(shiny) shinyUI(fluidPage( titlePanel("")
library(shiny)
shinyUI(fluidPage(
titlePanel(""),
sidebarLayout(
sidebarPanel(h2("Menu"),
br(),
fluidRow(column(12,
textInput("from", label = h4("From"),
value = "Unicentro, Bogotá"))),
fluidRow(column(12,
textInput("to", label = h4("To"),
value = "Calle 116 #20-50, Bogotá"))),
fluidRow(
column(6,
selectInput("mode", label = h5("Mode"),
choices = list("Walking" = "walking",
"Driving" = "driving",
"Transit" = "transit",
"Bike" = "bicycling"
), selected = 1)),
column(6,
numericInput("zoom",
label = h5("Zoom"),
value = 15))),
br(),
fluidRow(column(12,submitButton("Calculate Halfway Point"),align="center"))
),
mainPanel(h1("Halfway Point Map"),
p("NOTE: Wait a couple of second while we make the calculations and plot your map..."),
p("For correct result, the ZOOM scale must be accurate (contain both, the from and to places)"),
plotOutput("map",width=530, height=500),
h3("Halfway Exact Address"),
textOutput("dir"),
h4("Details of trayectory"),
tableOutput("tray")
)
)
))
对于server.R文件:
library(ggmap)
library(dplyr)
shinyServer(function(input, output) {
output$map <- renderPlot({
ggmap(get_map(geocode(c(input$from,input$to)), zoom = input$zoom, maptype='roadmap', source='google', color='color'))+
geom_segment(
aes(x = startLon, y = startLat, xend = endLon, yend = endLat),
colour ="red", size = 1, data = route(input$from, input$to, mode=input$mode)) +
geom_point(aes(x = halfLon, y = halfLat),
data = route(input$from, input$to, mode=input$mode) %>% mutate(cum.m = cumsum(m)) %>%
filter(cum.m >= sum(route(input$from, input$to, mode=input$mode)[1])/2) %>%
top_n(-1,cum.m) %>%
mutate(halfLon = startLon+(endLon-startLon)*(1-(cum.m-sum(route(input$from, input$to, mode=input$mode)[1])/2)/m),
halfLat = startLat+(endLat-startLat)*(1-(cum.m-sum(route(input$from, input$to, mode=input$mode)[1])/2)/m)) %>%
select(halfLon,halfLat),
colour = "black", size = 3)
})
output$dir <- renderText({
paste(
revgeocode(c(
as.numeric(route(input$from, input$to, mode=input$mode) %>% mutate(cum.m = cumsum(m)) %>%
filter(cum.m >= sum(route(input$from, input$to, mode=input$mode)[1])/2) %>%
top_n(-1,cum.m) %>%
mutate(halfLon = startLon+(endLon-startLon)*(1-(cum.m-sum(route(input$from, input$to, mode=input$mode)[1])/2)/m),
halfLat = startLat+(endLat-startLat)*(1-(cum.m-sum(route(input$from, input$to, mode=input$mode)[1])/2)/m)) %>%
select(halfLon)),
as.numeric(route(input$from, input$to, mode=input$mode) %>% mutate(cum.m = cumsum(m)) %>%
filter(cum.m >= sum(route(input$from, input$to, mode=input$mode)[1])/2) %>%
top_n(-1,cum.m) %>%
mutate(halfLon = startLon+(endLon-startLon)*(1-(cum.m-sum(route(input$from, input$to, mode=input$mode)[1])/2)/m),
halfLat = startLat+(endLat-startLat)*(1-(cum.m-sum(route(input$from, input$to, mode=input$mode)[1])/2)/m)) %>%
select(halfLat))),
output="address"),
" | ",
sum(route(input$from, input$to, mode=input$mode)[1])/2,
"m", sep="")
})
output$tray <- renderTable({
route(input$from, input$to, mode=input$mode) %>%
select(-startLon,-startLat,-endLon,-endLat) %>%
mutate(cum.m = cumsum(m))
})
})
我附上一对屏幕截图右R和左Shinyapps.io
链接:
希望你能在这件事上帮我,因为这让我发疯了!谢谢。我正在检查您的应用程序,您似乎已经修复了它。请分享解决方案。您应该将重复的代码放在几个反应中。此错误通常发生在代表中call@67342343我还没修好。。检查下面的图片@HubertL我真的没有在Shiny上做太多的工作,但是我在定义函数或reactive中的对象时遇到了一些麻烦。你知道我在哪里可以看到一些例子,看看我是否可以清理一些代码?关于rep错误,我的代码上的rep调用在哪里?图片: