Convert from annual to quarterly data, constrained to annual average

后端 未结 3 2115
走了就别回头了
走了就别回头了 2021-01-06 08:16

I have several variables at annual frequency in R that I would like to include in a regression analysis with other variables available at quarterly frequency. Additionally,

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-06 09:04

    Perhaps I'm missing something here, but assuming the annual value always comes from the first quarter, couldn't you just replace mean in your aggregate call with min?

     > d <- aggregate(c, as.integer(format(index(c),"%Y")), min, na.rm=TRUE)
     > d
          z_a z_q
     2000 100 100
     2001 110 110
     2002 111 111
    

提交回复
热议问题