So I have a dataset with variables
A_1 B_1 A_2 B_2 A_3 B_3......A_721 B_721
I made variable C_1
using an ifelse statement with A_1
and B_1
. Something like:
Data$C_1 <- ifelse(A_1 - B_1 <= 365 & A_1 - B_1 >= 0, 1, 0)
I want to make this rerun 721 times, to create C_1
to C_721
using the respective A and B variables.
All the examples of loops I find online run down a single column, and not across enumerated columns like I want to do here.
I apologize for the simplistic example, but I'm not sure if I can do this using a loop, or apply, or where to start.