У меня есть массив списков:
M <- array(list(numeric(2)), 5)
> M
[[1]]
[1] 0 0
[[2]]
[1] 0 0
[[3]]
[1] 0 0
[[4]]
[1] 0 0
[[5]]
[1] 0 0
Я хочу добавить к этим спискам векторы фиксированной длины, например, 2, как этот
x = as.numeric(1:2)
Я пытался
> M[1][2] = x
Warning messages:
1: In M[1][2] = x :
number of items to replace is not a multiple of replacement length
2: In M[1][2] = x :
number of items to replace is not a multiple of replacement length
> M[1]
[[1]]
[1] 0 0
и
> M[1][[2]] = x
Warning message:
In M[1][[2]] = x :
number of items to replace is not a multiple of replacement length
> M[1]
[[1]]
[1] 0 0
Я хочу, чтобы вывод был таким:
> M[1]
[[1]]
[1] 0 0
[[2]]
[1] 1 2
Как я могу это сделать?