row-bind data frames in a list of lists
Arguments
- x
list of lists each of which contains a data frame in element elementName
- elementName
name of list element in each sublist of x which contains a data frame
Examples
x <- list(
list(
number = 1,
data = data.frame(x = 1:2, y = 2:3)
),
list(
number = 2,
data = data.frame(x = 11:12, y = 12:13)
)
)
safeRowBindOfListElements(x, "data")
#> x y
#> 1 1 2
#> 2 2 3
#> 3 11 12
#> 4 12 13
# also working if the column names of the data frames in the "data" elements
# differ.
x[[1]]$data$z = 13:14
safeRowBindOfListElements(x, "data")
#> x y z
#> 1 1 2 13
#> 2 2 3 14
#> 3 11 12 NA
#> 4 12 13 NA