Reputation: 565
there is a list which I have which has several sublists - in every sublist there is a martix
lis[[1]]
V1 V2
386434 2999996820 0.03302860
386435 2999996860 0.03659760
386436 2999996950 0.02551180
386437 2999996960 0.00188527
lis[[2]]
2 249999983 0.00687375
3 250000122 0.02909420
4 250000225 0.00153139
5 250000301 0.26182100
the matrixes are not of equal dimension (same number of cols is true)
how can I without using rbind again and again in a single line or somth...just rbind alle the tables in the sublists to a single large table?
result i
V1 V2
386434 2999996820 0.03302860
386435 2999996860 0.03659760
386436 2999996950 0.02551180
386437 2999996960 0.00188527
2 249999983 0.00687375
3 250000122 0.02909420
4 250000225 0.00153139
5 250000301 0.26182100
Upvotes: 0
Views: 473
Reputation: 1123
Try the following:
total = Reduce(rbind, lis)
or
library("dplyr")
total = bind_rows(lapply(lis, as.data.frame))
Upvotes: 1
Reputation: 94182
For any list you can call any function with the list elements as if they were arguments of the function with do.call
. Hence:
do.call(rbind, lis)
should do it. Its equivalent to doing:
rbind(lis[[1]], lis[[2]], lis[[3]]......)
and so on for however many elements there are.
Upvotes: 0