diff
'll do it. (Note that you will need to prepend a 0
to 'pick up' the first step, from 0 to 9.)
diff(c(0, sample1))
# [1] 9 0 15 0 3 0 12 6 9 0 0 3 0 0 0 9 0 3 6
# [20] 6 9 12 3 3 12 0 3
Pergunta
sample1 <- c(9,9,24,24,27,27,39,45,54,54,54,57,57,57,57,66,66,69,75,81,90,102,105,108,120,120,123)
how can i make this to (9,0,15,0,3,0...) and so on? what this procedure called?
Solução
diff
'll do it. (Note that you will need to prepend a 0
to 'pick up' the first step, from 0 to 9.)
diff(c(0, sample1))
# [1] 9 0 15 0 3 0 12 6 9 0 0 3 0 0 0 9 0 3 6
# [20] 6 9 12 3 3 12 0 3