如何“转置"向量列表? [英] How to "transpose" a list of vectors?
本文介绍了如何“转置"向量列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个向量列表:
asdf = list(c(1, 2, 3, 4, 5), c(10, 20, 30, 40, 50))
现在我要转置"它,即得到一个5对的列表,而不是5对的列表.
Now I want to "transpose" it, that is, obtain a list of 5 pairs instead of a pair of lists of 5.
更具体地说,我希望结果类似于键入的结果:
To be more specific, I want the result to be analogous to the result of typing:
transposedAsdf = list(c(1, 10), c(2, 20), c(3, 30), c(4, 40), c(5, 50))
但我不知道如何实现这一点.怎么做?
But I don't know how to achieve this. How to?
推荐答案
Map
来自 base R
do.call(Map, c(f = c, asdf))
这篇关于如何“转置"向量列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文