I have the following code and want to write it with "apply" family of functions in order to decrease the time consumption. And are there another things that can be changed to optimize the operation?

ord_db is a tibble with several millions of rows.

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

n <- ord_db[i, "Date"]

if(n == 43465){

z <- 0

}else if (n == 43466 | n == 43831 | n == 44196){

z <- ord_db$Value[i]

}else {

z <- ord_db$Value[i] - ord_db$Prev_Date_Value[i]

}

ord_db$Value_change[I] <- z

}