我创建了一个列表,我想命名列表的元素。有人可以帮我吗?
LL <- vector(mode = "list")
L11 <- seq(1, 10)
L12 <- seq(11, 20)
LL[[length(LL)+1]] <- cbind(L11, L12)
# I want to name LL[[1]] as "L1", but this does not work
names(LL[[length(LL)]]) <- c("L1")
L21 <- seq(21, 30)
L22 <- seq(31, 40)
LL[[length(LL)+1]] <- cbind(L21, L22)
# I want to name LL[[2]] as "L2", but this does not work
names(LL[[length(LL)]]) <- c("L2")
LL
答案 0 :(得分:0)
这应该有效
LL <- vector(mode = "list")
LL$l1 <- seq(1, 10)
LL$l2 <- seq(11, 20)
答案 1 :(得分:0)