R:browseURL(x,...)出错:' url'必须是非空字符串

时间:2015-03-02 03:57:09

标签: r

我的代码如下:

#devtools::install_github("rstudio/leaflet")
library(leaflet)
set.seed(123)
m = leaflet() %>% addTiles()
rand_lng = function(n = 10) rnorm(n, -93.65, .01)
rand_lat = function(n = 10) rnorm(n, 42.0285, .01)
m %>% addCircles(rand_lng(50), rand_lat(50), radius = runif(50, 10, 200))

尝试使用它时,我收到此错误:

Error in browseURL(x, ...) : 'url' must be a non-empty character string

以下是sessionInfo()的结果:

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:

[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:

[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:

[1] leaflet_0.0.9   maps_2.3-9      magrittr_1.5    leafletR_0.3-1
[5] jsonlite_0.9.14 brew_1.0-6      sp_1.0-17      

loaded via a namespace (and not attached):

 [1] bitops_1.0-6      devtools_1.7.0    digest_0.6.8      evaluate_0.5.5    
 [5] formatR_1.0       grid_3.1.2        htmltools_0.2.6   htmlwidgets_0.3.2
 [9] httr_0.6.1        knitr_1.9         lattice_0.20-29   RCurl_1.95-4.5    
[13] RJSONIO_1.3-0     stringr_0.6.2     tools_3.1.2

以下是traceback()的结果:

    traceback()
    4: stop("'url' must be a non-empty character string")
    3: browseURL(x, ...)
    2: print.leaflet(list(x = list(calls = list(list(method = "tileLayer", 
   args = list("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", 
       list(minZoom = 0, maxZoom = 18, maxNativeZoom = NULL, 
           tileSize = 256, subdomains = "abc", errorTileUrl = "", 
           tms = FALSE, continuousWorld = FALSE, noWrap = FALSE, 
           zoomOffset = 0, zoomReverse = FALSE, opacity = 1, 
           zIndex = NULL, unloadInvisibleTiles = NULL,          updateWhenIdle =       NULL, 
           detectRetina = FALSE, reuseTiles = FALSE, attribution = "&copy; <a href=\"http://openstreetmap.org\">OpenStreetMap</a> contributors, <a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA</a>"))), 
   list(method = "circle", args = list(c(42.0310331851399, 42.0282145324465, 
   42.0280712954271, 42.0421860228401, 42.0262422901434, 42.0436647060443, 
   42.0130124719577, 42.0343461374964, 42.0297385424384, 42.0306594156874, 
   42.0322963948276, 42.0234767654689, 42.0251679261633, 42.0183142461689, 
   42.0177820877352, 42.031535286414, 42.0329820977863, 42.0290300422673, 
   42.0377226746788, 42.0490008468563, 42.0235896883394, 42.0054083112436, 
   42.0385573852446, 42.0214079923742, 42.0216199138353, 42.038755713697, 
   42.0256522699295, 42.0162928228775, 42.0303130347975, 42.0271110863756, 
   42.028557641859, 42.0323528040113, 42.0247933996821, 42.0349437654852, 
   42.0262951343818, 42.0318178196392, 42.0394683901315, 42.0328518149083, 
   42.0252406841447, 42.0399880761845, 42.0384350385596, 42.0339839695951, 
   42.0308873173511, 42.0222209392396, 42.0421065244853, 42.0224974041285, 
   42.0503733299302, 42.0438261062619, 42.026142996409, 42.0182357909969
   ), c(-93.6556047564655, -93.6523017748948, -93.6344129168585, 
   -93.6492949160858, -93.6487071226484, -93.6328493501312, 
   -93.6453908379401, -93.6626506123461, -93.6568685285189, 
   -93.654456619701, -93.6377591820256, -93.6464018617294, -93.6459922854941, 
   -93.6488931728406, -93.6555584113475, -93.632130868632, -93.6450214952177, 
   -93.6696661715663, -93.6429864409844, -93.6547279140773, 
   -93.6606782370599, -93.6521797491466, -93.6602600444831, 
   -93.6572889122929, -93.6562503926785, -93.6668669331074, 
   -93.6416221295551, -93.6484662688216, -93.6613813693701, 
   -93.6374618507893, -93.6457353577852, -93.6529507148299, 
   -93.6410487433896, -93.6412186651247, -93.6417841891836, 
   -93.643113597459, -93.6444608234646, -93.6506191171058, -93.6530596266374, 
   -93.6538047100101, -93.6569470697892, -93.6520791727802, 
   -93.6626539635157, -93.6283104403466, -93.637920380017, -93.661231085832, 
   -93.654028848353, -93.6546665535362, -93.6422003488166, -93.6508336906647
   ), c(55.3579451004043, 192.848197922576, 124.259487935342, 
   107.85564817721, 86.4889350184239, 177.246842833702, 79.177454309538, 
   64.7654633317143, 42.4225946702063, 42.7126318123192, 101.588095049374, 
   58.0633364175446, 51.0884100268595, 138.131513735279, 19.0560892107897, 
   143.162086619996, 76.8588413065299, 87.6993596064858, 165.980751551688, 
   184.582896148786, 63.6803827201948, 192.609910804313, 148.394941370934, 
   140.411265580915, 20.0403491267934, 85.0918255816214, 100.79062217148, 
   116.448120099958, 142.66970302444, 183.979872299824, 127.486733200494, 
   91.4000866631977, 112.9952697712, 21.1109128315002, 59.5628028409556, 
   85.4588711285032, 47.5714999693446, 168.066236937884, 39.0485723363236, 
   162.649522984866, 113.896969745401, 135.840351982042, 42.6227138377726, 
   130.28051836649, 69.2552518867888, 147.665325817652, 85.7985666859895, 
   194.17771811597, 193.805690417066, 148.073482413311), NULL, 
       list(lineCap = NULL, lineJoin = NULL, clickable = TRUE, 
           pointerEvents = NULL, className = "", stroke = TRUE, 
           color = "#03F", weight = 5, opacity = 0.5, fill = TRUE, 
           fillColor = "#03F", fillOpacity = 0.2, dashArray = NULL), 
       NULL))), limits = list(lat = c(42.0054083112436, 42.0503733299302
     ), lng = c(-93.6696661715663, -93.6283104403466))), width = NULL, 
   height = NULL, sizingPolicy = list(defaultWidth = "100%", 
       defaultHeight = 400, padding = 0, viewer = list(defaultWidth =      NULL, 
           defaultHeight = NULL, padding = NULL, fill = TRUE, 
           suppress = FALSE, paneHeight = NULL), browser = list(
           defaultWidth = NULL, defaultHeight = NULL, padding = NULL, 
           fill = TRUE), knitr = list(defaultWidth = NULL, defaultHeight = NULL, 
           figure = TRUE)), dependencies = NULL, elementId = NULL))
     1: print(list(x = list(calls = list(list(method = "tileLayer", args = list(
   "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", list(
       minZoom = 0, maxZoom = 18, maxNativeZoom = NULL, tileSize = 256, 
       subdomains = "abc", errorTileUrl = "", tms = FALSE, continuousWorld = FALSE, 
       noWrap = FALSE, zoomOffset = 0, zoomReverse = FALSE, 
       opacity = 1, zIndex = NULL, unloadInvisibleTiles = NULL, 
       updateWhenIdle = NULL, detectRetina = FALSE, reuseTiles = FALSE, 
       attribution = "&copy; <a href=\"http://openstreetmap.org\">OpenStreetMap</a> contributors, <a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA</a>"))), 
   list(method = "circle", args = list(c(42.0310331851399, 42.0282145324465, 
   42.0280712954271, 42.0421860228401, 42.0262422901434, 42.0436647060443, 
   42.0130124719577, 42.0343461374964, 42.0297385424384, 42.0306594156874, 
   42.0322963948276, 42.0234767654689, 42.0251679261633, 42.0183142461689, 
   42.0177820877352, 42.031535286414, 42.0329820977863, 42.0290300422673, 
   42.0377226746788, 42.0490008468563, 42.0235896883394, 42.0054083112436, 
   42.0385573852446, 42.0214079923742, 42.0216199138353, 42.038755713697, 
   42.0256522699295, 42.0162928228775, 42.0303130347975, 42.0271110863756, 
   42.028557641859, 42.0323528040113, 42.0247933996821, 42.0349437654852, 
   42.0262951343818, 42.0318178196392, 42.0394683901315, 42.0328518149083, 
   42.0252406841447, 42.0399880761845, 42.0384350385596, 42.0339839695951, 
   42.0308873173511, 42.0222209392396, 42.0421065244853, 42.0224974041285, 
   42.0503733299302, 42.0438261062619, 42.026142996409, 42.0182357909969
   ), c(-93.6556047564655, -93.6523017748948, -93.6344129168585, 
   -93.6492949160858, -93.6487071226484, -93.6328493501312, 
   -93.6453908379401, -93.6626506123461, -93.6568685285189, 
   -93.654456619701, -93.6377591820256, -93.6464018617294, -93.6459922854941, 
   -93.6488931728406, -93.6555584113475, -93.632130868632, -93.6450214952177, 
   -93.6696661715663, -93.6429864409844, -93.6547279140773, 
   -93.6606782370599, -93.6521797491466, -93.6602600444831, 
   -93.6572889122929, -93.6562503926785, -93.6668669331074, 
   -93.6416221295551, -93.6484662688216, -93.6613813693701, 
   -93.6374618507893, -93.6457353577852, -93.6529507148299, 
   -93.6410487433896, -93.6412186651247, -93.6417841891836, 
   -93.643113597459, -93.6444608234646, -93.6506191171058, -93.6530596266374, 
   -93.6538047100101, -93.6569470697892, -93.6520791727802, 
   -93.6626539635157, -93.6283104403466, -93.637920380017, -93.661231085832, 
   -93.654028848353, -93.6546665535362, -93.6422003488166, -93.6508336906647
   ), c(55.3579451004043, 192.848197922576, 124.259487935342, 
   107.85564817721, 86.4889350184239, 177.246842833702, 79.177454309538, 
   64.7654633317143, 42.4225946702063, 42.7126318123192, 101.588095049374, 
   58.0633364175446, 51.0884100268595, 138.131513735279, 19.0560892107897, 
   143.162086619996, 76.8588413065299, 87.6993596064858, 165.980751551688, 
   184.582896148786, 63.6803827201948, 192.609910804313, 148.394941370934, 
   140.411265580915, 20.0403491267934, 85.0918255816214, 100.79062217148, 
   116.448120099958, 142.66970302444, 183.979872299824, 127.486733200494, 
   91.4000866631977, 112.9952697712, 21.1109128315002, 59.5628028409556, 
   85.4588711285032, 47.5714999693446, 168.066236937884, 39.0485723363236, 
   162.649522984866, 113.896969745401, 135.840351982042, 42.6227138377726, 

   130.28051836649, 69.2552518867888, 147.665325817652, 85.7985666859895, 
   194.17771811597, 193.805690417066, 148.073482413311), NULL, 
       list(lineCap = NULL, lineJoin = NULL, clickable = TRUE, 
           pointerEvents = NULL, className = "", stroke = TRUE, 
           color = "#03F", weight = 5, opacity = 0.5, fill = TRUE, 
           fillColor = "#03F", fillOpacity = 0.2, dashArray = NULL), 
       NULL))), limits = list(lat = c(42.0054083112436, 42.0503733299302
      ), lng = c(-93.6696661715663, -93.6283104403466))), width = NULL, 
   height = NULL, sizingPolicy = list(defaultWidth = "100%", 
       defaultHeight = 400, padding = 0, viewer = list(defaultWidth = NULL, 
           defaultHeight = NULL, padding = NULL, fill = TRUE, 
           suppress = FALSE, paneHeight = NULL), browser = list(
           defaultWidth = NULL, defaultHeight = NULL, padding = NULL, 
           fill = TRUE), knitr = list(defaultWidth = NULL, defaultHeight = NULL, 
           figure = TRUE)), dependencies = NULL, elementId = NULL))

1 个答案:

答案 0 :(得分:0)

根据此链接,我不知道确切的原因,但黑客为我工作了。 (https://github.com/rstudio/leaflet/issues/50)。

问题实际上是&#34; leafletR&#34;包。关闭Rstudio并重新启动它并确保&#34; leafletR&#34;没有安装。它对我有用。