I want to create a matrix for N groups and T time periods. For each combination of T-N, I want to have a random number of lines.
The random number of lines for each N-T is given by round(runif(1,2,4)).
The goal is to have as input :
set.seed(123)
ngroup = 2
tperiod = 2
Using round(runif(1,2,4)) 4 times gives 3,4,3,4, so the output should have :
- 3 lines for group 1 time 1
- 4 lines for group 1 time 2
- 3 lines for group 2 time 1
- 4 lines for group 2 time 2
And as the output should be :
mat = cbind(c(1,1,1,1,1,1,1,2,2,2,2,2,2,2), c(1,1,1,2,2,2,2,1,1,1,2,2,2,2))
mat
[,1] [,2]
[1,] 1 1
[2,] 1 1
[3,] 1 1
[4,] 1 2
[5,] 1 2
[6,] 1 2
[7,] 1 2
[8,] 2 1
[9,] 2 1
[10,] 2 1
[11,] 2 2
[12,] 2 2
[13,] 2 2
[14,] 2 2
Where the 1st column is the group ID, and the 2nd the time ID.