For example, using column 1 as the matching criterion, lets call replicate(length(v), sum(v))
for the column 2 vector, v
, of every set of rows that consists of contiguous and matching rows from the data frame A
(including sets of size 1).
A v
a 12
a 43
b 8
a 4
b 12
c 5
c 9
d 21
->
55, 55, 8, 4, 12, 14, 14, 21
The operation can return a vector or a list of vectors that we can coerce to a vector with unlist()
.