使用 leaflet 和 google sheets 部署 shiny 应用程序时出错 API
Error in deploying shinyapp using leaflet and googlesheets API
我正在开发一个在本地运行的 shinyapp,但每次我尝试在 shinyapps.io 上发布它时都会抛出错误。
我已经使用 leaflet 发布了应用程序并且它们可以正常工作,我还在其他应用程序中使用了 googlesheets 并且该软件包也可以正常工作。但是当我完全使用它们时,应用程序 returns Error : there is no package called ‘leaflet’.
这很奇怪,因为在此示例应用程序中它确实找到了包。
传单制作:
library(shiny)
library(leaflet)
# UI
ui <-(fluidPage("Example", leafletOutput("map")))
# Server
server = (function(input, output) {
output$map <- renderLeaflet({
leaflet() %>%
addProviderTiles("CartoDB.Positron") %>%
setView(-58.43152, -34.6052, zoom=11 )
})
})
shinyApp(ui = ui, server = server)
传单不 工作:
library(shiny)
library(leaflet)
library(googlesheets)
library(sp)
library(rgdal)
library(DT)
options("googlesheets.httr_oauth_cache" = "gs_auth")
gs_auth()
rdv <- gs_url("https://docs.google.com/spreadsheets/d/1eWxmy7kSjWVfloJiS4ycjn4YKx2OybIzWogX7ga4fUQ/edit?usp=sharing", lookup = NULL, visibility = NULL, verbose = TRUE)
shape <- readRDS("shape_ok.rds")
bounds <- bbox(shape)
sheet <- gs_read(rdv, ws = 3)
# UI
ui <-(fluidPage("Example",
leafletOutput("map"),
dataTableOutput("table")
)
)
# Server
server = (function(input, output) {
output$map <- renderLeaflet({
leaflet(shape) %>%
addProviderTiles("CartoDB.Positron") %>%
setView(-58.43152, -34.6052, zoom=11 ) %>%
addPolygons(stroke = T, fillOpacity = 0.65, smoothFactor = 0.5)
})
output$table <- renderDataTable({ as.data.frame(sheet) })
})
# Run the application
shinyApp(ui = ui, server = server)
我还部署了仅使用 googlesheets 的应用程序,它们可以正常工作。因此,当我同时使用这两个包并收到传单错误时,我不知道发生了什么。
我下载了一个阿根廷 RDS 文件并让它在本地工作而无需更改(尽管有警告)。我也在URL:https://mikewise2718.shinyapps.io/Argentina/
成功发布到shinyapps.io
我用的RStudio版本:0.99.903
所以这可能是某种版本问题,这是我的 sessionInfo()
:
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DT_0.2 rgdal_1.1-10 sp_1.2-3 googlesheets_0.2.1 leaflet_1.0.1 shiny_0.14.2
loaded via a namespace (and not attached):
[1] Rcpp_0.12.7 xml2_1.0.0 magrittr_1.5 xtable_1.8-2 lattice_0.20-34 R6_2.2.0 stringr_1.1.0 httr_1.2.1 dplyr_0.5.0
[10] tools_3.3.2 grid_3.3.2 DBI_0.5-1 htmltools_0.3.5 yaml_2.1.14 lazyeval_0.2.0 openssl_0.9.5 assertthat_0.1 digest_0.6.10
[19] tibble_1.2 RJSONIO_1.3-0 readr_1.0.0 purrr_0.2.2 bitops_1.0-6 htmlwidgets_0.8 RCurl_1.95-4.8 rsconnect_0.4.3 curl_2.2
[28] mime_0.5 stringi_1.1.2 cellranger_1.1.0 jsonlite_1.1 httpuv_1.3.3
我正在开发一个在本地运行的 shinyapp,但每次我尝试在 shinyapps.io 上发布它时都会抛出错误。
我已经使用 leaflet 发布了应用程序并且它们可以正常工作,我还在其他应用程序中使用了 googlesheets 并且该软件包也可以正常工作。但是当我完全使用它们时,应用程序 returns Error : there is no package called ‘leaflet’.
这很奇怪,因为在此示例应用程序中它确实找到了包。
传单制作:
library(shiny)
library(leaflet)
# UI
ui <-(fluidPage("Example", leafletOutput("map")))
# Server
server = (function(input, output) {
output$map <- renderLeaflet({
leaflet() %>%
addProviderTiles("CartoDB.Positron") %>%
setView(-58.43152, -34.6052, zoom=11 )
})
})
shinyApp(ui = ui, server = server)
传单不 工作:
library(shiny)
library(leaflet)
library(googlesheets)
library(sp)
library(rgdal)
library(DT)
options("googlesheets.httr_oauth_cache" = "gs_auth")
gs_auth()
rdv <- gs_url("https://docs.google.com/spreadsheets/d/1eWxmy7kSjWVfloJiS4ycjn4YKx2OybIzWogX7ga4fUQ/edit?usp=sharing", lookup = NULL, visibility = NULL, verbose = TRUE)
shape <- readRDS("shape_ok.rds")
bounds <- bbox(shape)
sheet <- gs_read(rdv, ws = 3)
# UI
ui <-(fluidPage("Example",
leafletOutput("map"),
dataTableOutput("table")
)
)
# Server
server = (function(input, output) {
output$map <- renderLeaflet({
leaflet(shape) %>%
addProviderTiles("CartoDB.Positron") %>%
setView(-58.43152, -34.6052, zoom=11 ) %>%
addPolygons(stroke = T, fillOpacity = 0.65, smoothFactor = 0.5)
})
output$table <- renderDataTable({ as.data.frame(sheet) })
})
# Run the application
shinyApp(ui = ui, server = server)
我还部署了仅使用 googlesheets 的应用程序,它们可以正常工作。因此,当我同时使用这两个包并收到传单错误时,我不知道发生了什么。
我下载了一个阿根廷 RDS 文件并让它在本地工作而无需更改(尽管有警告)。我也在URL:https://mikewise2718.shinyapps.io/Argentina/
成功发布到shinyapps.io我用的RStudio版本:0.99.903
所以这可能是某种版本问题,这是我的 sessionInfo()
:
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DT_0.2 rgdal_1.1-10 sp_1.2-3 googlesheets_0.2.1 leaflet_1.0.1 shiny_0.14.2
loaded via a namespace (and not attached):
[1] Rcpp_0.12.7 xml2_1.0.0 magrittr_1.5 xtable_1.8-2 lattice_0.20-34 R6_2.2.0 stringr_1.1.0 httr_1.2.1 dplyr_0.5.0
[10] tools_3.3.2 grid_3.3.2 DBI_0.5-1 htmltools_0.3.5 yaml_2.1.14 lazyeval_0.2.0 openssl_0.9.5 assertthat_0.1 digest_0.6.10
[19] tibble_1.2 RJSONIO_1.3-0 readr_1.0.0 purrr_0.2.2 bitops_1.0-6 htmlwidgets_0.8 RCurl_1.95-4.8 rsconnect_0.4.3 curl_2.2
[28] mime_0.5 stringi_1.1.2 cellranger_1.1.0 jsonlite_1.1 httpuv_1.3.3