问题
I have list 1:
l1 <- list(letters[1:26])
I have list 2:
l2 <- list(c(1:26))
How would I combine l1
and l2
into a new list l4
with 52 elements: the first 26 elements are the elements of l1
and the next 26 are the elements of l2
?
回答1:
You could use c
to combine them
l4 <- c(l1[[1]], l2[[1]])
Or with unlist
l4 <- c(unlist(l1), unlist(l2))
Maybe you want to wrap it in list
l4 <- list(c(l1[[1]], l2[[1]]))
来源:https://stackoverflow.com/questions/60229489/splitting-list-into-its-components-and-combine-to-form-another-list-in-r