将两个data.frames列表绑定到一个新列表 [英] cbind two lists of data.frames to a new list
本文介绍了将两个data.frames列表绑定到一个新列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个data.frames列表。这两个列表具有相同的长度,并在其相应的列表元素中包含合适的data.frames。
因此情况如下:
I have two lists of data.frames. Both lists have the same length and contain fitting data.frames in their according list elements. So the scenario looks like this
dfa = data.frame(a=1:3, b = letters[1:3])
dfb = data.frame(x=runif(3))
a = replicate(3, dfa, simplify = FALSE)
b = replicate(3, dfb, simplify = FALSE)
一个明显的解决方案是:
One obvious solution is:
lapply(seq_along(a), function(i) cbind(a[[i]], b[[i]]))
但是我想知道它们是否是更好的解决方案。
But I was wondering if their might be a better solution.
推荐答案
您可以使用 Map
Map(cbind, a, b)
这篇关于将两个data.frames列表绑定到一个新列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文