On 10/15/09, Henrique Dallazuanna <www...@gmail.com> wrote: > 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"), to, from) > > 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) > } > > Hmm.. There are still some inconsistencies: > foo('EUR', 'RUB', '2009-10-16') ### slightly wrong [1] 43.830 > foo('RUB', 'EUR', '2009-10-16') [1] 0.0228 #Friday, October 16, 2009 #1 Euro = 43.85951 Russian Rouble #1 Russian Rouble (RUB) = 0.02280 Euro (EUR) #Median price = 43.82953 / 43.85951 (bid/ask)
It seems that EUR/RUB reports the median data. For other pairs (say, EUR/PEN) the discrepancies can be more obvious. Thank you Liviu ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.