找回密码
 立即注册
查看: 4499|回复: 0

列表下标问题

[复制链接]
发表于 2015-10-24 18:52:14 | 显示全部楼层 |阅读模式
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"

为什么第二种是对的呢?[]和[[]]有什么区别呢?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|R语言中文网

GMT+8, 2024-11-23 18:57 , Processed in 0.029174 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表