I need to calculate the maximum consumption value based on the previous values every time I loop the consumption data. For example on day 4, the maximum consumption would be calculated from day 1 to 4.
Follow the code I thought, but I do not know how it can be calculated
Maxconsumo<-c()
for (i in 1:length(Consumo)) {
Maxconsumo <- .........
}
Dia Consumo
1 245
2 256
3 300
4 450
5 245
6 256
7 300
8 450