On Sat, Mar 3, 2018 at 7:06 PM, bigappleanalyst <[hidden email]> wrote:

I have a flat file that I imported into R. The file is 10,000 rows. In the
file there is a date variable, and a group variable. There are 100 groups,
so the group variable shows a value of 1 for rows 1:100, a value of 2 for
rows 101:200, and so on for all 100 groups. The date variable has 100 unique
entries, and repeats/restarts for each group. Thus, the dates in rows 1:100
are identical to the dates in rows 101:200, 201:300, and so on.

I wrote a function that manipulates a vector in the flat file, vector_1. As
it stands, it manipulates vector_1 across all 10,000 rows. Vector_1 has
unique entries in rows 1:100, 101:200, 201:300, and so on. Thus, I would
like to implement a parameter so the function only calculates across the
specified range. If I input group = 1, then the function will only perform
the calculation on vector_1 for rows 1:100.

I would like to implement a parameter or a loop that performs the
calculation over the corresponding range of vector_1 for the inputted group
parameter value. For example, if I instead entered group =2 the function
would look like: