我想让list元素的值等于另一个列表,就像这样......
list_one <- as.list(c(A = NA, B = NA))
list_two <- as.list(c(C = 4, D = 5))
list_one['A'] <- list_two
这引发了以下警告:
Warning message:
In list_one["A"] <- list_two :
number of items to replace is not a multiple of replacement length
如何正确制作list_two
list_one
的子列表,以便我不会收到此警告?
答案 0 :(得分:2)
使用[[
代替[
list_one[['A']] <- list_two