set a b; (stack; align names with rename= if needed)
bind_rows(..., .id = "SRC")
add a source variable before set
bind_rows() by column name
PROC SQLOUTER UNION CORR
Trap: bind_rows() matches columns by name, not position. A type clash on the same name (character vs numeric) errors or coerces; fix types before stacking.
Worked examples below.
Stack two tables
library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
.id adds a column with the list names. Useful when you need to know which input row came from.
ImportantMatch by name, not position
bind_rows() does not line up column 1 with column 1. Rename first when the same concept has different names. When the same name has different types, fix the type before stacking.
For side-by-side combines on keys, use joins (see Joins), not bind_rows().