# How to find the difference between the sums of consecutive pairs and triplets in R?

I know how to use diff (, lag = 1, difference = 1) to find the interval in every two consecutive lines, i.e. r2-r1, r3-r2, etc.

But I'm wondering how to find the distances (difference) between the sums of consecutive pairs and triplets in R. In other words, for consecutive triplets, spacing1 = (r4 + r5 + r6) - (r1 + r2 + r3), etc.

thank

+1

source to share

No one has answered this question yet

See similar questions:

or similar: