I have two list composed of dataframes (in the example 3 dataframes by list). I would like to bind the rows of dataframes of the two lists.
I was thinking to couple rbind()
with Map()
, map()
or lapply()
:
Map(rbind,List1,List2)
However when I apply that code, I have a binding of only one dataframe of the first list to another one of in the second list. Given only three final dataframes in the final output. While I would like that each dataframe of the first list being binded by each dataframe of the second list. Given a output of 9 dataframe instead of the 3 I have actually.
If I have a List1 composed of df-a, df-b, df-c, and a List2 composed of df-1, df-2, df-3
I would like to have the final combination of dataframe in the list :
- a-1,
- a-2,
- a-3,
- b-1,
- b-2,
- b-3,
- c-1,
- c-2,
- c-3
instead of that, with the code on above I only have :
How could I fix this issue?
On below, you will find an example of lists:
List 1
<code>List1 <- structure(list(structure(list(Values = c(3.95464079265625, 4.28848139983694,
4.59263295848293, 4.87348316186162, 5.13543268303855, 5.38166290292844,
5.61456044441555, 5.8359690473681, 6.04734746369445, 6.24987292533157
), array = c(10, 12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("1",
"1", "1", "1", "1", "1", "1", "1", "1", "1")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L)), structure(list(
Values = c(6.82179666846063, 7.09317719563801, 7.33103172027803,
7.54350812736648, 7.73603145714462, 7.91240924925746, 8.07542410682578,
8.22717585659922, 8.36929092723351, 8.50305660066192), array = c(10,
12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("2", "2", "2",
"2", "2", "2", "2", "2", "2", "2")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L)), structure(list(
Values = c(4.30943511800407, 4.62131690026944, 4.90255443339214,
5.15997082435108, 5.39822432778288, 5.62065617021581, 5.8297555323974,
6.02743344284351, 6.21519337899337, 6.39424241723516), array = c(10,
12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("3", "3", "3",
"3", "3", "3", "3", "3", "3", "3")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L))), ptype = structure(list(
Values = numeric(0), array = numeric(0), ID = character(0)), class = c("tbl_df",
"tbl", "data.frame"), row.names = integer(0)), class = c("vctrs_list_of",
<code>List1 <- structure(list(structure(list(Values = c(3.95464079265625, 4.28848139983694,
4.59263295848293, 4.87348316186162, 5.13543268303855, 5.38166290292844,
5.61456044441555, 5.8359690473681, 6.04734746369445, 6.24987292533157
), array = c(10, 12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("1",
"1", "1", "1", "1", "1", "1", "1", "1", "1")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L)), structure(list(
Values = c(6.82179666846063, 7.09317719563801, 7.33103172027803,
7.54350812736648, 7.73603145714462, 7.91240924925746, 8.07542410682578,
8.22717585659922, 8.36929092723351, 8.50305660066192), array = c(10,
12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("2", "2", "2",
"2", "2", "2", "2", "2", "2", "2")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L)), structure(list(
Values = c(4.30943511800407, 4.62131690026944, 4.90255443339214,
5.15997082435108, 5.39822432778288, 5.62065617021581, 5.8297555323974,
6.02743344284351, 6.21519337899337, 6.39424241723516), array = c(10,
12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("3", "3", "3",
"3", "3", "3", "3", "3", "3", "3")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L))), ptype = structure(list(
Values = numeric(0), array = numeric(0), ID = character(0)), class = c("tbl_df",
"tbl", "data.frame"), row.names = integer(0)), class = c("vctrs_list_of",
"vctrs_vctr", "list"))
</code>
List1 <- structure(list(structure(list(Values = c(3.95464079265625, 4.28848139983694,
4.59263295848293, 4.87348316186162, 5.13543268303855, 5.38166290292844,
5.61456044441555, 5.8359690473681, 6.04734746369445, 6.24987292533157
), array = c(10, 12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("1",
"1", "1", "1", "1", "1", "1", "1", "1", "1")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L)), structure(list(
Values = c(6.82179666846063, 7.09317719563801, 7.33103172027803,
7.54350812736648, 7.73603145714462, 7.91240924925746, 8.07542410682578,
8.22717585659922, 8.36929092723351, 8.50305660066192), array = c(10,
12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("2", "2", "2",
"2", "2", "2", "2", "2", "2", "2")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L)), structure(list(
Values = c(4.30943511800407, 4.62131690026944, 4.90255443339214,
5.15997082435108, 5.39822432778288, 5.62065617021581, 5.8297555323974,
6.02743344284351, 6.21519337899337, 6.39424241723516), array = c(10,
12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("3", "3", "3",
"3", "3", "3", "3", "3", "3", "3")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L))), ptype = structure(list(
Values = numeric(0), array = numeric(0), ID = character(0)), class = c("tbl_df",
"tbl", "data.frame"), row.names = integer(0)), class = c("vctrs_list_of",
"vctrs_vctr", "list"))
List 2
<code>structure(list(structure(list(Values = c(8.17331050066691, 8.87216395029884,
9.50945470046081, 10.098386534235, 10.6480633233427, 11.1650711748644,
11.6543539639589, 12.1197331206333, 12.5642336602292, 12.9902979406118
), array = c(10, 12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("1",
"1", "1", "1", "1", "1", "1", "1", "1", "1")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L)), structure(list(
Values = c(7.98726323968068, 8.65441558454706, 9.26177728829764,
9.82224562340532, 10.3446999917905, 10.8355558754145, 11.2996236117639,
11.7406176335271, 12.1614755496734, 12.5645671491611), array = c(10,
12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("2", "2", "2",
"2", "2", "2", "2", "2", "2", "2")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L)), structure(list(
Values = c(7.34557601230256, 8.06135956556851, 8.72069616000395,
9.33527354603708, 9.9132220632988, 10.4604689570926, 10.9814938935561,
11.4797806661262, 11.9581023062164, 12.4187090723963), array = c(10,
12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("3", "3", "3",
"3", "3", "3", "3", "3", "3", "3")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L))), ptype = structure(list(
Values = numeric(0), array = numeric(0), ID = character(0)), class = c("tbl_df",
"tbl", "data.frame"), row.names = integer(0)), class = c("vctrs_list_of",
<code>structure(list(structure(list(Values = c(8.17331050066691, 8.87216395029884,
9.50945470046081, 10.098386534235, 10.6480633233427, 11.1650711748644,
11.6543539639589, 12.1197331206333, 12.5642336602292, 12.9902979406118
), array = c(10, 12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("1",
"1", "1", "1", "1", "1", "1", "1", "1", "1")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L)), structure(list(
Values = c(7.98726323968068, 8.65441558454706, 9.26177728829764,
9.82224562340532, 10.3446999917905, 10.8355558754145, 11.2996236117639,
11.7406176335271, 12.1614755496734, 12.5645671491611), array = c(10,
12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("2", "2", "2",
"2", "2", "2", "2", "2", "2", "2")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L)), structure(list(
Values = c(7.34557601230256, 8.06135956556851, 8.72069616000395,
9.33527354603708, 9.9132220632988, 10.4604689570926, 10.9814938935561,
11.4797806661262, 11.9581023062164, 12.4187090723963), array = c(10,
12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("3", "3", "3",
"3", "3", "3", "3", "3", "3", "3")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L))), ptype = structure(list(
Values = numeric(0), array = numeric(0), ID = character(0)), class = c("tbl_df",
"tbl", "data.frame"), row.names = integer(0)), class = c("vctrs_list_of",
"vctrs_vctr", "list"))
</code>
structure(list(structure(list(Values = c(8.17331050066691, 8.87216395029884,
9.50945470046081, 10.098386534235, 10.6480633233427, 11.1650711748644,
11.6543539639589, 12.1197331206333, 12.5642336602292, 12.9902979406118
), array = c(10, 12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("1",
"1", "1", "1", "1", "1", "1", "1", "1", "1")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L)), structure(list(
Values = c(7.98726323968068, 8.65441558454706, 9.26177728829764,
9.82224562340532, 10.3446999917905, 10.8355558754145, 11.2996236117639,
11.7406176335271, 12.1614755496734, 12.5645671491611), array = c(10,
12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("2", "2", "2",
"2", "2", "2", "2", "2", "2", "2")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L)), structure(list(
Values = c(7.34557601230256, 8.06135956556851, 8.72069616000395,
9.33527354603708, 9.9132220632988, 10.4604689570926, 10.9814938935561,
11.4797806661262, 11.9581023062164, 12.4187090723963), array = c(10,
12, 14, 16, 18, 20, 22, 24, 26, 28), ID = c("3", "3", "3",
"3", "3", "3", "3", "3", "3", "3")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L))), ptype = structure(list(
Values = numeric(0), array = numeric(0), ID = character(0)), class = c("tbl_df",
"tbl", "data.frame"), row.names = integer(0)), class = c("vctrs_list_of",
"vctrs_vctr", "list"))