R cbinding lists of data.tables

谁都会走 提交于 2020-12-15 04:40:47

问题


I have two lists of data.tables of equal length in R. I want to element-wise cbind them. I sort of want to do a zip function where the input is two lists and the output is one list as illustrated below:

list1 list2                  list3
----- -----       ----------------
 dt1a  dt2a       cbind(dt1a,dt2a)
 dt1b  dt2b  =>   cbind(dt1b,dt2b)
 dt1c  dt2c       cbind(dt1c,dt2c)

What is the easiest way to do this?


回答1:


list3 <- mapply(cbind, list1, list2, SIMPLIFY=FALSE)


来源:https://stackoverflow.com/questions/48233811/r-cbinding-lists-of-data-tables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!