Combine two lists in a dataframe in R

后端 未结 6 2216
青春惊慌失措
青春惊慌失措 2021-02-07 08:46

I have two lists with different structure:

listA <- list(c(\"a\",\"b\",\"c\"), c(\"d\",\"e\"))
listB <- list(0.05, 0.5)

listA
[[1]]
[1] \"a\" \"b\" \"c\"
         


        
6条回答
  •  广开言路
    2021-02-07 09:23

    Here is another way:

    do.call(rbind,
            lapply(1:length(listA),
                   function(i)
                     data.frame(A=unlist(listA[i]),
                                B=unlist(listB[i]))))
    

提交回复
热议问题