Are there are any R packages/functions to get exchange rates in real time, e.g. from Google Finance? Would prefer to avoid RCurl or other parsers if something\'s already out
Looks like TFX and quantmod have functions for this (thanks to @RStudent and @KFB for the tips). I preferred quantmod since it didn't require setting up an account, but AFAICT there's no vectorized current-snapshot function like what I'm seeking. This function GetExchangeRates does this:
GetExchangeRates <- function(from, to, dt=Sys.Date()) {
require(quantmod)
obj.names <- getFX(paste0(from, "/", to), from=dt, to=dt)
result <- numeric(length(obj.names))
names(result) <- obj.names
for (obj.name in obj.names) {
result[obj.name] <- as.numeric(get(obj.name))[1]
# Clean up
rm(obj.name)
}
return(result)
}
TestExchangeRates <- function() {
from <- c("CAD", "JPY", "USD")
to <- c("USD", "USD", "EUR")
GetExchangeRates(from, to)
}