0
for (i in 1:nrow(df2)){

if (df2$FLAG[i]==0) {df2$AGE[i]<-50}}

df2 is a data frame with around 500,000 rows. So this takes a lot of time to run. Is there a way to optimize this in R?

Ujjwal
  • 3,088
  • 4
  • 28
  • 36

0 Answers0