fname = file.choose()
two = read.csv(fname.header=T)
rec = two$Receipt
del = two$Delivery
date = two$Date
net = rec-del
yrec = matrix(rec,nrow=365,ncol=4,byrow=F)
ydel = matrix(del,nrow=365,ncol=4,byrow=F)
ynet = matrix(net,nrow=365,ncol=4,byrow=F)
yrecsum = 0
yrecavg = 0
for(i in 1:4)
{
for(j in 1:365)
{
yrecsum[i] = yrecsum[i]+yrec[j,i]
}
yrecavg[i] = yrecsum[i]/365
}
So what I have are three matrices of the same size with days in integers (from 1 to 365) on the rows and years integers (from 1 to 4) on the columns. Each matrix is filled in with the data that I'm working with.
I'm trying to find the average of each column for all three matrices and I would like to put those averages in a vector for each matrix.
I've looked around and found some information about the zoo library and chron library and such but I can't get those to work.
this should get you started (even though I would convert the matrices to data.frames):
if you have 3 matrices and you want to combine the results I would do: