I am downloading data from FRED with getSymbols. This creates an xts class object with the data attribute set to type integer for the series' that I am downloading. I want these data to be of type/class double. What is an idiomatic way of doing this?
getSymbols("GDPMC1", src = 'FRED', auto.assign = TRUE)
growthRate <-
function (x) {
stopifnot(length(x) > 1)
(x[2:length(x)] - x[-length(x)] )/ x[-length(x)]
}
stopifnot(growthRate(c(2,3,4)) == c(0.5 , 1/3 ))
realGDPGrowthRate <- growthRate(GDPMC1) ### zeros due to integer math