Hello On 10/14/09, Henrique Dallazuanna <www...@gmail.com> wrote: > foo('BRL', 'USD', '2009-10-14') > Nice function, thank you. Two issues, though: - it seems to provide reverse output. Example: ## how many dollars do you get "from" one euro? > foo('EUR', 'USD', '2009-10-14') [1] 0.67544 ## however, the equivalent of 1 Euro would be .. > 1/foo('EUR', 'USD', '2009-10-14') [1] 1.4805 ## .. dollars ## 1 Euro = 1.48051 US Dollar ## taken from the on-line converter
The dirty hack is to use "1/as.numeric(value)" as a return value. For describing the next issue I will use the improved version of the function. - second issue, for weaker currencies (that is, with more digits) the reported value is not necessarily correct. Example: ## fine > foo('EUR', 'RUB', '2009-10-14') [1] 43.745 ## fine > 1/foo('EUR', 'RUB', '2009-10-14') [1] 0.02286 ## wrong > foo('RUB', 'EUR', '2009-10-14') [1] 0.26878 ## taken from the on-line converter ## 1 Euro = 43.75188 Russian Rouble ## 1 Russian Rouble (RUB) = 0.02286 Euro (EUR) I am not sure on how to fix this one. 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.