Hi everyone,
Following this post:
http://r.789695.n4.nabble.com/currency-conversion-function-tt906056.html#a906061
I was trying to run the code:
foo <- function(from, to, date){
url <- "
http://www.oanda.com/convert/classic?script=..%2Fconvert%2Fclassic&language=en&value=1
"
params <-
sprintf("%s&date=%s&exch=%s&exch2=&margin_fixed=0&expr=%s&expr2=&SUBMIT=Convert+Now&lang=en&date_fmt=us",
url, format(as.Date(date), "%m/%d/%y"), from, to)
Lines <- readLines(params)
value <- gsub(".*([0-9]\\.+[0-9]+).*", "\\1",
grep("nl", grep(from,
grep(to, Lines, value = TRUE), value = TRUE), value = TRUE))
as.numeric(value)
}
foo('BRL', 'USD', '2010-10-14')
But it gives me the following:
numeric(0)
Warning message:
In readLines(params) :
incomplete final line found on '
http://www.oanda.com/convert/classic?script=..%2Fconvert%2Fclassic&language=en&value=1&date=10/14/10&exch=BRL&exch2=&margin_fixed=0&expr=USD&expr2=&SUBMIT=Convert+Now&lang=en&date_fmt=us
'
Does anyone what the problem is about?
If I type simply:
> getFX("EUR/USD",from="2011-01-01")
Then I get similar error:
[1] "EURUSD"
Warning message:
In readLines(tmp) :
incomplete final line found on
'xxx\AppData\Local\Temp\RtmpI1HUzb\file27f7532'
>
(I've hide the path)
Thanks
[[alternative HTML version deleted]]