Skip to content
Prev 317453 / 398506 Next

date and matrices

Hi,

Just forgot about one thing:
With more matrices with one column:
One way would be to combine them as a single matrix:
date1<-format(seq.Date(as.Date("1991.1.1",format="%Y.%m.%d"),as.Date("1996.12.31",format="%Y.%m.%d"),by="day"),"%Y.%m.%d")

mat1<-matrix(c(.314,.314,.273,.273,.236,.236,.236,.236,.273,.314,.403,.314),ncol=1)
mat2<-matrix(c(.314,.325,.246,.273,.226,.236,.249,.236,.289,.314,.403,.314),ncol=1)
mat3<- cbind(mat1,mat2) #if this is not feasible, tell me how these matrices are named

?res2<- lapply(seq_len(ncol(mat3)),function(i) cbind(date1,c(rep(mat3[,i],182),head(mat3[,i],8))))
head(res2[[1]])
#???? date1?????????????? 
#[1,] "1991.01.01" "0.314"
#[2,] "1991.01.02" "0.314"
#[3,] "1991.01.03" "0.273"
#[4,] "1991.01.04" "0.273"
#[5,] "1991.01.05" "0.236"
#[6,] "1991.01.06" "0.236"
?tail(res2[[1]])
#??????? date1?????????????? 
#[2187,] "1996.12.26" "0.273"
#[2188,] "1996.12.27" "0.273"
#[2189,] "1996.12.28" "0.236"
#[2190,] "1996.12.29" "0.236"
#[2191,] "1996.12.30" "0.236"
#[2192,] "1996.12.31" "0.236"


A.K.