1
我在整個過程中搜索過SO,但無法找到解決方案。如何將列表插入(合併)到列表中
這裏是例子:
m1 <- data.frame(matrix(1:4, nrow = 2, ncol = 2))
m2 <- data.frame(matrix(9:14, nrow = 3, ncol = 2))
mlist <- list(m1, m2)
b1 <- c(1,-1)
b2 <- c(1,-1,1)
blist <- list(b1, b2)
期望的結果:
[[1]]
X1 X2 new
1 1 3 1
2 2 4 -1
[[2]]
X1 X2 new
1 9 12 1
2 10 13 -1
3 11 14 1
'lapply (seq_along(blist),function(i){cbind(mlist [[i]],new = blist [[i]])})'但是都列出h大約是相同的長度和順序,你希望他們在。 – hrbrmstr
是的,我想過類似的解決方案,認爲會有更好的功能,而不是循環通過元素。 – Maximilian