I am trying to create a matrix like this from a vector:
vec =c(1, 2, 3)
> A
[,1] [,2] [,3] [,4] [,5]
[1,] 1 1 0 0 0
[2,] 1 2 1 0 0
[3,] 1 3 2 1 0
and each time the length and value of vector vec
is changing. How can I write a function to create this matrix?