赞
踩
#列表循环添加元素
lst <- list()
n <- 1
for(i in 1:10)
{
lst[[i]] <- n
n <- n + 1
}
> lst
[[1]]
[1] 1
[[2]]
[1] 2
[[3]]
[1] 3
[[4]]
[1] 4
[[5]]
[1] 5
[[6]]
[1] 6
[[7]]
[1] 7
[[8]]
[1] 8
[[9]]
[1] 9
[[10]]
[1] 10
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。