I have a dataframe as below
string1 string2 var1 var2
T T 1 1
T F 0 1
F F 0 0
I want to iterate through each row which has n number of rows and add conditions like below
Iterate n number of rows
if(string1 == T & sting2 == F){
if(va1 > 1 & var2 > 1){
# do some operation and append to new column
# For example
new column <- var1 + var2
}
elif(var1 == 0 & var2 > 1){
# Do some adds / subs with var1 & var2 and append to new column
}
elif{var1 > 1 & var2 ==0){
# Do some adds / subs with var1 & var2 and append to new column
}
}
elif(string1 == F & sting2 == T){
# again repeat set of if-else opration on var1 and var2 as mentioned in
above if else condition
}
elif(nth condition)
How do i achieve in R