x <- c(.5, 0.2, 2, 3.4, 0.4, 1.2, .2, .8, 2.3, 7.4)
result.final <- NULL
cumul.total <- 0
for (i in x) {
cumul.total <- cumul.total + i
if(i > 1){
result <- cumul.total
}
else {
next
}
result.final <- c(result.final, result)
}
result.final
8
solved R programming – if/else command [closed]