rbind_by_list_pos: Row-binds data.tables in a list of lists

View source: R/helpers.R

rbind_by_list_posR Documentation

Row-binds data.tables in a list of lists

Description

This function takes a list of lists of data.tables (or anything that data.table::rbind accepts, like data.frames), and then row-binds them by position or name. For example, if passed list(list(first=A,second=B),list(first=C,second=D)), you would get back list(first=rbind(A,C),second=rbind(B,D)).

Usage

rbind_by_list_pos(dtl, ignore_names = FALSE)

Arguments

dtl

List of lists of data.tables.

ignore_names

If the list is named, match objects across lists only by their position in the list and not by their names.

Examples


list_of_lists <- list(
    list(data.frame(a = 1), data.frame(a = 2), data.frame(a = 3)),
    list(data.frame(a = 4), data.frame(a = 5), data.frame(a = 6))
)
rbind_by_list_pos(list_of_lists)

list_of_named_lists <- list(
    list(A = data.frame(a = 1), B = data.frame(a = 2), C = data.frame(a = 3)),
    list(C = data.frame(a = 4), A = data.frame(a = 5), B = data.frame(a = 6))
 )
rbind_by_list_pos(list_of_named_lis)


SafeGraphInc/SafeGraphR documentation built on Nov. 25, 2022, 11:20 a.m.