【问题标题】:How can I suppress Google's messages when using ggmap with knitr?将 ggmap 与 knitr 一起使用时,如何抑制 Google 的消息?
【发布时间】:2013-08-20 18:59:41
【问题描述】:

当使用ggmapknitr .Rnw 文件时,如何在输出.pdf 中抑制Google 的消息? .Rnw 文件的 MWE 代码用于生成说明问题的 .pdf

\documentclass{article}
\begin{document}
<<>>=
library(ggmap)
qmap("empire state building", zoom=15, messaging=FALSE, source="google") 
@
\end{document}

在生成的.pdf 中,出现以下(格式错误的)消息:

Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=empire+state+building&zoom=15&size=%20640x640&scale=%202&maptype=terrain&sensor=false
Google Maps API Terms of Service : http://developers.google.com/maps/terms  
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=empire+state+building&sensor=false  
Google Maps API Terms of Service : http://developers.google.com/maps/terms  

如何抑制这些消息?我希望messaging=FALSE 会这样做。

【问题讨论】:

  • suppressMessages 工作吗?
  • message = FALSE 不是messaging = FALSE?
  • messaging = FALSEggmap 文档中指定。另外,感谢您的解决方案。

标签: r knitr ggmap


【解决方案1】:

您可以使用message = FALSE 来抑制代码块的任何消息

<<themap, message = FALSE>>=
library(ggmap)
qmap("empire state building", zoom = 15, messaging = FALSE, source = "google") 
@

抑制这些消息。

查看ggmap::qmap,它以可能被认为允许使用不同sources 的非标准方式评估... 中的参数。似乎verboseRgoogleMaps::GetMap 的参数没有被解析或传递,messaging(get_googlemap 的参数)也没有)

【讨论】:

    猜你喜欢
    • 2023-03-21
    • 1970-01-01
    • 2018-11-01
    • 1970-01-01
    • 2014-05-29
    • 1970-01-01
    • 2016-10-15
    • 2017-03-03
    • 1970-01-01
    相关资源
    最近更新 更多