I have a data frame containing weights for stocks in a portfolio, it is around 1000 stocks and 4000 days of data. I want to apply the weights of the first day of each month to all days of that month. However, I still want to retain the structure of daily data.
My data is similar to this:
data<-as.data.frame(matrix(1:4000,nrow=200,ncol=20))
rownames(data)<-seq(as.Date("2018/01/01"),as.Date("2018/07/19"),1)
So I want to have the values of the first of January copied to all days of January, values of the first day of February copied to all days in Februari etc. I have no clue how to handle this.
Any tips?
Aucun commentaire:
Enregistrer un commentaire