来自quantmod的getSymbols无法从命令行运行

时间:2014-06-30 20:59:38

标签: r quantmod

我已经能够使用getSymbols函数从RStudio中成功地从默认源(yahoo)中提取财务数据。当我尝试从命令行在脚本中运行它时,此操作失败并且不返回任何数据。当我从命令行手动输入命令时也一样。

代码:

library(quantmod)
args <- commandArgs(FALSE)
options("getSymbols.warning4.0"=FALSE)
getSymbols("APL")
chartSeries(APL, subset='last 1 months')
saveChart('png')

错误:

Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : 
unable to connect to 'chart.yahoo.com' on port 80.

我是从运行Windows Server 2008的VM执行此操作。有什么想法吗?我希望能够从PHP调用此代码以在用户访问页面时更新图形

1 个答案:

答案 0 :(得分:0)

快速确定您是否可以通过R:使用RCurl::getURL

连接到互联网
if (is.character(getURL("www.google.com"))) {
   out <- TRUE
} else {
   out <- FALSE
}

来自:&lt; How to determine if you have an internet connection in R? &GT;

相关问题