how can I reflect the vector relative to the last value, I don't know how to explain it in words, so I will show it with pictures
I tried to do it myself, but my code only works with linear vector
x <- 1:10
y <- rev(cumsum(c(tail(x,1),diff(x))))
plot(rep(NA,20),t="l" , ylim = c(1,20))
lines(x,col=2,lwd=5)
lines(y,col=4,lty=5)
If you take an arbitrary vector, my code doesn't work
set.seed(123)
x <- cumsum(rnorm(10)) # real vector
y <- rev(cumsum(c(tail(x,1),diff(x))))
plot(rep(NA,20),t="l" , ylim = c(-5,10))
lines(x,col=2,lwd=5)
lines(y,col=4,lty=5)
Aucun commentaire:
Enregistrer un commentaire