Согласно ?"["
(в разделе «рекурсивные (подобные списку) объекты»):
Indexing by ‘[’ is similar to atomic vectors and selects a list of
the specified element(s).
Both ‘[[’ and ‘$’ select a single element of the list. The main
difference is that ‘$’ does not allow computed indices, whereas
‘[[’ does. ‘x$name’ is equivalent to ‘x[["name", exact =
FALSE]]’. Also, the partial matching behavior of ‘[[’ can be
controlled using the ‘exact’ argument.
В основном для списков [
выбирает более одного элемента, поэтому замена должнабыть списком (не вектором, как в вашем примере).Вот пример использования [
в списках:
l <- list(c(1,2,3), c(4,5,6))
l[1] <- list(1:2)
l[1:2] <- list(1:3,4:5)
Если вы хотите заменить только один элемент, используйте вместо него [[
.
l[[1]] <- 1:3