Accessing the internet with knitr

狂风中的少年 提交于 2019-12-25 14:26:06

问题


When I run some code to draw a map using ggmap, in Rstudio it runs fine. When I run it using knitr it fails with the following error message:-

Error in download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") :
cannot open URL 'http://maps.googleapis.com/maps/api/staticmap?center=-40.851253,172.799669&zoom=19&size=%20640x640&scale=%202&maptype=hybrid&sensor=false'
Calls: ... eval -> eval -> get_map -> get_googlemap -> download.file
In addition: Warning message:
In download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") : unable to connect to 'maps.googleapis.com' on port 80.
Execution halted

I am sure this is due to the way our network is set up, probably around permissions, but is anyone able to give me any clues as to how knitr would try to access the internet to download a map so I may be able to find a way though our firewall.

Code added but it works fine except through our network.

---
title: "Drawing a map"
author: "Alasdair Noble"
output: word_document
---




To draw a map

```{r echo=TRUE, warning=FALSE ,  results='markup', comment="",message=FALSE }
library(ggplot2)
library(grid)
library(GGally)
library(plyr)
library(RColorBrewer)
library(ggmap)
library(ggthemes)

```




```{r echo=TRUE, warning=FALSE ,  results='markup', comment="", message=FALSE }

Btrcup <- get_map(location=c(lon=171.799669, lat=-42.851253),zoom=19,      maptype="hybrid")
Btrcupmap <- ggmap(Btrcup)

Btrcupmap

```

来源:https://stackoverflow.com/questions/32466608/accessing-the-internet-with-knitr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!