using getSymbols to load different start time vari

2019-08-30 14:09发布

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.

标签: r quantmod
1条回答
贼婆χ
2楼-- · 2019-08-30 14:50

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
查看更多
登录 后发表回答