list[[1]] <- list(c("a","b","c"),c("x","y","z"))运行结果:
[[1]]
[1] "a" "b" "c"
[[2]]
[1] "x" "y" "z"
我如果再扩充list,以下两种方式:
(1)list[[1]][1] <- c("X","Y","Z")
【运行结果】
Warning message:
In list2002[[3]][3] <- c("X", "Y", "Z") :
number of items to replace is not a multiple of replacement length
(2)list[[1]][[1]] <- c("X","Y","Z")
【运行结果】
> list2002[[3]][[3]]
[1] "X" "Y" "Z"
为什么第二种是对的呢?[]和[[]]有什么区别呢?
|