cbind items from multiple lists recursively

ぃ、小莉子 提交于 2019-12-05 11:14:09

Or like this:

mapply(cbind, one, two, three)

Or like this:

mylist <- list(one, two, three)
do.call(mapply, c(cbind, mylist))

Use Reduce and Map (Map being a simple wrapper for mapply(..., SIMPLIFY = FALSE)

Reduce(function(x,y) Map(cbind, x, y),list(one, two,three))

When using Reduce or most of the functional programming base functions in R, you usually can't pass arguments in ... so you normally need to write a small anonymous function to do what you want.

sep.list <- unlist(list(one, two, three), recursive = FALSE)
lapply(split(sep.list, names(sep.list)), do.call, what = cbind)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!