0

I have been able to use the getSymbols function to draw financial data from the default source (yahoo) successfully from within RStudio. When I tried to run this in a script from the command line, this fails and returns no data. The same when I manually enter the command from the command line.

Code:

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

Error:

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

I'm executing this from a VM running Windows Server 2008. Any ideas? I want to be able to call this code from PHP to update a figure when the user visits a page

ClintI
  • 27
  • 7
  • This is problem with your internet connection. It has nothing to do with `getSymbols`, quantmod, or R. I'll guess that you're behind a proxy. – Joshua Ulrich Jun 30 '14 at 21:04
  • Joshua - yes, I am. But why would it block access from command line but not from RStudio? – ClintI Jul 01 '14 at 12:44
  • Because someone configured the RStudio server to use the proxy... – Joshua Ulrich Jul 01 '14 at 12:48
  • In the same RStudio session I can successfully pull using quantmod:getSymbols, however cannot get connection using RCurl:getURL for google. Any ideas there? – ClintI Jul 01 '14 at 13:20

1 Answers1

0

Quick way to determine if you can connect to the internet via R: using RCurl::getURL

if (is.character(getURL("www.google.com"))) {
   out <- TRUE
} else {
   out <- FALSE
}

from: < How to determine if you have an internet connection in R ? >

Community
  • 1
  • 1
Rime
  • 912
  • 2
  • 11
  • 39