Hello community, I try to replace values in one variable from another, using a for loop. and it gives me a warning that I don't understand, (number of items to replace is not a multiple of replacement length) the code I'm using is the following:
attach(ENCFT_20191)
table(pension_ext_moneda,periodo)
p_s4d21_1 <- ifelse(pension_ext==1 , pension_ext_monto, NA )
for(i in 1:length(pension_ext_moneda)) {
if(pension_ext_moneda[i]=="EUR" & periodo[i] == 201901) p_s4d21_1[i]= pension_ext_monto*tcR[2,6] else
if (pension_ext_moneda[i]=="USD" & periodo[i] == 201901) p_s4d21_1[i]= pension_ext_monto*tcR[3,6] else
if (pension_ext_moneda[i]=="REAL" & periodo[i] == 201901) p_s4d21_1[i] = pension_ext_monto*tcR[4,6]
}