Got it. below is the entire code. Trying to see if you can spot what the error is?
'''r
R_code <- for (j in 1:50) {
for (i in 1:639) {
if (imputations[["imputations"]][[paste("imp",j,sep="")]][["B1PRSEX"]][i]==1) {
imputations[["imputations"]][[paste("imp",j,sep="")]][['L']][i]=
0.49716*(imputations[["imputations"]][[paste("imp",j,sep="")]][["B1PAGE_M2"]][i]/10)+
0.47254imputations[["imputations"]][[paste("imp",j,sep="")]][["CIGSTA"]][i]+
0.45341imputations[["imputations"]][[paste("imp",j,sep="")]][["HXCVD"]][i]+
0.08064*imputations[["imputations"]][[paste("imp",j,sep="")]][["HXofAFib"]][i]
if (imputations[["imputations"]][[paste("imp",j,sep="")]][["B1PAGE_M2"]][i]>=65) {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+0.45426
} else {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+0
}
if (imputations[["imputations"]][[paste("imp",j,sep="")]][["DxDMperGlu"]][i]==1) {
if (imputations[["imputations"]][[paste("imp",j,sep="")]][["B1PAGE_M2"]][i]>=65) {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+0.34385
} else {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+1.35304
}
} else {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+0
}
if (imputations[["imputations"]][[paste("imp",j,sep="")]][["AntiHyperMed"]][i]==1) {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+0.82598+
(0.09793*(imputations[["imputations"]][[paste("imp",j,sep="")]][["B4P1GS23"]][i]-120)/10)
} else {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+
(0.27323*(imputations[["imputations"]][[paste("imp",j,sep="")]][["B4P1GS23"]][i]-120)/10)
}
} else {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
0.87938*(imputations[["imputations"]][[paste("imp",j,sep="")]][["B1PAGE_M2"]][i]/10)+
0.51127*imputations[["imputations"]][[paste("imp",j,sep="")]][["CIGSTA"]][i]-
0.03035*imputations[["imputations"]][[paste("imp",j,sep="")]][["HXCVD"]][i]+
1.2072*imputations[["imputations"]][[paste("imp",j,sep="")]][["HXofAFib"]][i]
if (imputations[["imputations"]][[paste("imp",j,sep="")]][["B1PAGE_M2"]][i]>=65) {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+0.39796
} else {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+0
}
if (imputations[["imputations"]][[paste("imp",j,sep="")]][["DxDMperGlu"]][i]==1) {
if (imputations[["imputations"]][[paste("imp",j,sep="")]][["B1PAGE_M2"]][i]>=65) {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+0.06565
} else {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+1.07111
}
} else {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+0
}
if (imputations[["imputations"]][[paste("imp",j,sep="")]][["AntiHyperMed"]][i]==1) {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+0.13085+
(0.17234*(imputations[["imputations"]][[paste("imp",j,sep="")]][["B4P1GS23"]][i]-120)/10)
} else {
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]=
imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]+
(0.11303*(imputations[["imputations"]][[paste("imp",j,sep="")]][["B4P1GS23"]][i]-120)/10)
}
}
if (imputations[["imputations"]][["imp1"]][["B1PRSEX"]][i]==1) {
imputations[["imputations"]][[paste("imp",j,sep="")]][["FRFS"]][i]=
(1-0.94451)*(exp(imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]-4.4227101))
} else {
imputations[["imputations"]][[paste("imp",j,sep="")]][["FRFS"]][i]=
(1-0.95911)*(exp(imputations[["imputations"]][[paste("imp",j,sep="")]][["L"]][i]-6.6170719))
}
}
}
'''