Analyze Data Frames In A List And Bind The Results

不羁的心 提交于 2019-12-05 19:21:44

Loop through the list, create a condition with if/else that checks the length of the unique column names and returns the unlisted single data.frame when there is only a single unique column or else return the first column. Finally, with cbind.fill (from rowr) bind the list of data.frame columns together, specifying the fill as 0

lst2 <- lapply(lst1, function(x) if(length(unique(names(x))) ==1)
     setNames(data.frame(unlist(x)), names(x)[1]) else x[1])
do.call(rowr::cbind.fill, c(lst2, list(fill = 0)))
#    A.DIODE B.DIODE
#1     1.2     1.4
#2     0.4     0.8
#3     1.3     0.0
#4     0.6     0.0
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!