using getSymbols to load different start time variables (time series data)

余生颓废 提交于 2019-12-12 01:21:21

问题


getSymbols(c("PI","RSXFS", "TB3MS", src="FRED",from="1959-1-1",  from="1992-1", from="1934-1-1")

How can I load data by using getSymbols for different start dates for multiple variables?

I needs 200 variables from FRED. I can download the FRED CODE easily, but the problem is that dates. Each variables have different starting date. First I load data set with time series format and then i will use window commend for fixing the same time period for all 200 data.


回答1:


May be you are looking for mapply

symbols<-c("PI","RSXFS", "TB3MS")
begin.date<-c("1959-1-1","1992-1", "1934-1-1")
jj<- mapply(function(sym,dt) getSymbols(sym, src="FRED", from=dt,auto.assign = FALSE),symbols,begin.date)

head(jj[[3]])
           TB3MS
1934-01-01  0.72
1934-02-01  0.62
1934-03-01  0.24
1934-04-01  0.15
1934-05-01  0.16
1934-06-01  0.15


来源:https://stackoverflow.com/questions/30897606/using-getsymbols-to-load-different-start-time-variables-time-series-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!