Dear Valleria, please make your matrix structure clea and begin its row from a1 instead of a14. I do not understand if your a14 is c(rep(0,4),b,rep(0,79)) what the elements of matrix rows a1, a2, ...,a13 are?
Anyway, regarding the posted question this may help
This is just a quick and dirty coding. Acessing an index beyond the boundaries of the matrix a will cause an error. In this case using an index of arow>96, as the last index of b has to be written in a column greater 100, what was set to be the limitation here.
To write a loop in R to create a 100-by-100 matrix, where each row is a vector of 17 values and a lot of zeros with a shift, you can follow these steps:
Define the vector of 17 values, such as b in your example code.
Initialize an empty matrix with 100 rows and 100 columns, using the matrix() function with NA as the data argument.
Use a for loop to iterate over the rows of the matrix, from 1 to 100.
In each iteration, use the c() function to concatenate the vector of values with the appropriate number of zeros before and after it, depending on the row index. The number of zeros before the vector should be equal to the row index minus one, and the number of zeros after the vector should be equal to 100 minus the row index minus 16.
Assign the concatenated vector to the corresponding row of the matrix, using the [ ] operator with the row index as the first argument and nothing as the second argument.
End the for loop and return or print the matrix.
Here is an example code that implements these steps: