I have the below data frame
AccountNumber <- 123456
Tenure <- 3
x1<-0.890625
x2<-0.894634
x3<-0.814514
x4<-0.875413
x5<- 0.8765712
df <- data.frame(AccountNumber, Tenure,x1,x2,x3,x4,x5)
Based on the Tenure column , i have to create a new column Rate . If the Tenure is equal to 3 then , then Rate will pick the value 0.814514 from the third column(x3), If Tenure is 2 then Rate will pick the value 0.894634(from column x2) and so on .