I want to add a new column in my data frame so that for each row if LOC == 1 then V is equal to the value given for V1; if LOC==
LOC == 1
V
V1
LOC==
If LOC only contains 1 or 2 then this will work
LOC
df$V <- ifelse(df$LOC == 1, df$V1, df$V2)