# [R] date and matrices

arun smartpink111 at yahoo.com
Wed Feb 13 15:53:43 CET 2013

```Hi,

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

#     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.

________________________________
From: eliza botto <eliza_botto at hotmail.com>
To: "smartpink111 at yahoo.com" <smartpink111 at yahoo.com>
Sent: Wednesday, February 13, 2013 9:01 AM
Subject: date and matrices

Dear Arun,
[text files is also attached to be used in case format is changed]
i have 124 matrices with 12rows and 1 column. In all those 124 columns there are values of a certain quantity called disty. what i want to do is the following
1- insert a date column in each matrix in such a way that date should start from 1991. 1. 1 (yyyy. m. d) and should end at
1996.12.31.
2- against each date i want to put the values of quantity disty and as i have only 12 values of disty i want to start from the
first value after very 12 days.
more precisely, if i have a matrix like this
mat1
[,1]
.314
.314
.273
.273
.236
.236
.236
.236
.273
.314
.403
.314

i want it to be like the following one
1911. 1. 1      .314
1911. 1. 2      .314
1911. 1. 3      .273
1911. 1. 4      .273
1911. 1. 5      .236
1911. 1. 6      .236
1911. 1. 7      .236
1911. 1. 8      .236
1911. 1. 9      .273
1911. 1.10     2.314
1911. 1.11    12.403
1911. 1.12      .314
1911. 1.11      .314
1911. 1.12      .314
1911. 1.13      .273
1911. 1.14      .273
1911. 1.15      .236
1911. 1.16      .236
1911. 1.17      .236
1911. 1.18      .236
1911. 1.19      .273
1911. 1.20     2.314
1911. 1.21    12.403
1911. 1.22      .314
1911. 1.23      .314
1911. 1.24      .314
1911. 1.25      .273
1911. 1.26      .273
1911. 1.27      .236
1911. 1.28      .236
1911. 1.29      .236
1911. 1.30      .236
1911. 1.31      .273
1911. 2. 1     2.314
1911. 2. 2    12.403
1911. 2. 3      .314
1911. 2. 4      .314
1911. 2. 5      .314
1911. 2. 6      .273
1911. 2. 7      .273
1911. 2. 8      .236
1911. 2. 9      .236
1911. 2.10      .236
1911. 2.11      .236
1911. 2.12      .273
1911. 2.13     2.314
1911. 2.11    12.403
----------------------
----------------------
1911.12.17     12.403
------------------------
------------------------
------------------------
and so on till 1996
i also want these 124 matrices to be saved in my computer with the pattern exactly shown above. you can see if a value is in decimal number it is exactly 6 spaces away from the day number in date column. these spaces are subsequently reduced when the values go from decimal to higher.
Actually it wont be wrong to say the pattren of output text files saved in my computer should stricktly carry all the patterns as given above as i will later on use them in fortran.

```