I am looking to fill matrix tab with the output of the look (variable ma), however instead it is filling the matrix with NAs
MA<-data.matrix(my_data)
MA2=MA[-247,-8]
tab<-matrix(ncol=2,nrow=253)
ma4<-matrix(ncol=1,nrow=253)
tab[,1]<-MA2[,1]
for (n in 1:248) {
y<-MA2[c(n,n+1,n+2,n+3,n+4,n+5),5]
z<-sum(y)
mav<-z/5
tab[[n,2]]<-mav
n<-n+1
}
link to data is here https://uk.finance.yahoo.com/quote/LLOY.L/history?p=LLOY.L