【问题标题】:Consistent errors when uploading an R Leflet map to RPubs将 R Leflet 地图上传到 RPubs 时出现一致的错误
【发布时间】:2019-09-11 16:29:45
【问题描述】:

我正在尝试将大型传单地图 r 文件 (97.5mb) 从 RStudio 上传到 RPubs。我不断收到同样的错误,我想知道是否有人有解决方案/解决方法。错误状态:

"rawToChar(response$headers) 中的错误:参数 'x' 必须是原始的 矢量调用:... http -> -> grep -> parse_headers -> rawToChar 执行停止”

我构建了一个大型多边形等值线 shapefile,详细说明了宾夕法尼亚州、新泽西州和特拉华州的所有人口普查区域。当我在 RStudio 的查看器窗口中点击“发布”时,我首先被指示选择我想要发布文件的位置:RPubs 或 RStudio Connect。我有一个 RPubs 帐户,因此我选择了该选项,然后在第二个 RPubs 选项窗口中单击“发布”。然后我收到一个缓冲标签,后跟一条错误消息说明:

"rawToChar(response$headers) 中的错误:参数 'x' 必须是原始的 矢量调用:... http -> -> grep -> parse_headers -> rawToChar 执行停止”

这是我的地图的代码:

shapefile <- readOGR("filename")

shapefile <- spTransform(shapefile,"+proj=longlat +datum=WGS84")

### Creating the leaflet map ###
bins <- c(60,65,70,75,80,85,90,95)
pal <- colorBin("YlGnBu", domain=shapefile$lifeexpectancy, bins=bins)

m <- leaflet(shapefile) %>%
  addProviderTiles(providers$CartoDB.Positron) %>%
  setView(lng=-75.165222, lat=39.952583, 11) %>%
  addPolygons(fillColor = ~pal(lifeexpectancy),
              weight=0.5,
              opacity=1,
              color="gray",
              fillOpacity=0.4,
              highlightOptions = highlightOptions(color="white",
                                                  weight=1.5,
                                                  bringToFront = T,
                                                  opacity = 0.7),
              label=mapply(
                function(x,y) {
                  HTML(sprintf("<strong>Life Expectancy</strong><br/><em>%s years</em><br/><strong>Median Household Income</strong><br/><em>$%s</em>",
                               htmlEscape(x),htmlEscape(y)))
                },
                shaoefile$lifeexpectancy,shapefile$`Median Household Income`, SIMPLIFY = F),
              labelOptions = lapply(1:nrow(shapefile),function(x) {
                labelOptions(direction = "auto",
                             textsize = "15px")
              })) %>%
  addLegend(pal=pal,
            values=bins,
            opacity = 0.7,
            title ="Life Expectancy<br>(in years)",
            position="bottomright")

我也曾收到以下错误:

“curl::curl_fetch_memory(url, handle = handle) 中的错误:空 来自服务器调用的回复:... tryCatch -> tryCatchList -> tryCatchOne -> 计时停止于:0.03 0.05 1.3 执行 暂停”

我已经看到了有关在我的系统文件夹中修复 .Rprofile 代码的先前答案,但没有一个对我有用。您能提供的任何帮助都会很棒。

【问题讨论】:

  • 我刚刚遇到了同样的问题。你知道如何解决这个问题吗?

标签: r r-leaflet


【解决方案1】:

为了获得更纤细的 html 文件,您可以尝试简化多边形的几何形状。详情请见this notebook

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-19
    • 1970-01-01
    • 2013-10-15
    • 2023-03-03
    • 2019-11-15
    • 2015-10-08
    • 2018-05-03
    • 2011-09-07
    相关资源
    最近更新 更多