This currently only supports x with only one non-zero element
collect(x, along = 2)
x
A logical matrix
along
Which axis to spread mask on
A character vector or list thereof