Hello Everyone,

I am executing a for loop code for 100k+ rows and 50+ columns to apply a conditional formula across all element of the dataframe. Is there a logical way to make the code run faster

for(i in 1:nrow(dataframe)){

for(j in 4:column_number){

if(j <= min(dataframe$index[i] +6,column_number)){

dataframe[i,j] <- round(dataframe[i,j]*dataframe[i,col_12],0)

}else{

dataframe[i,j] <- 0

}

}

}

Thanks