select n rows, evaluate a condition, swap the columns if met using R : <p>I have a situation that I am curious to know how R can handle efficiently. let's say I have a data set that has two columns-V1 and V2.
Now, I want a way to evaluate column V1 and check in 3 rows at a time (i.e rows 1 to 3, then 4 to 6 and so on) for the following two conditions:-
a) do either of the 3 rows of V1 contain zero
b) do either of 3 rows of V1 contains a three digit number</p>

<p>if the conditions meet, then we swap the 3 values in V1 column with the values in V2.</p>

<p>I am struggling to find a way to do this in R. This has to be done over 500,000 rows and 5 columns, so efficiency would be important.</p>

<p>Thanks!</p>
