I was downloading historical data using the priceR
package with the historical_exchange_rates
function, but I am experiencing problems with the Yen. I have downloaded 10 other currencies and no problem, but the Yen/USD exchange rate is wrong, and it is the same as the Euro/USD. Does anyone know how to solve it?
Thanks
Here the code
library(priceR)
startDate <- "2006-01-01"
endDate <- "2020-12-31"
LPY_USD <- historical_exchange_rates("LPY", to = "USD",
start_date = startDate, end_date = endDate)
EUR_USD <- historical_exchange_rates("EUR", to = "USD",
start_date = startDate, end_date = endDate)
Thank you very much, in the confusion of all the code I didn't realise that the ISO name was wrong. Classic error of distraction. I'm almost ashamed to have asked this question. But it should give an error so that you can understand
CodePudding user response:
I think the problem is a typo - LPY
not JPY
. If the from or to parameters are a string it does not recognise it seems to default to euro and US. I cannot be sure though as the documentation doesn't state these defaults and the function provides no warnings or errors regarding the issue (which it really should).
For example, these both return the same values:
historical_exchange_rates(from="EUR", to="USD", start_date = "2006-01-01", end_date = "2006-01-05")
historical_exchange_rates(from="", to="", start_date = "2006-01-01", end_date = "2006-01-05")