How to write dynamic cumulative multiple in R -
suppose have vector x
as:
x <- c(x1, x2, x3, ..., xn)
i want write function automatically result series this:
y <- c(x1, x1*x2, x1*x2*x3, ..., x1*x2*x3*...*xn)
can tell me how in r?
have @ ?cumprod
:
cumprod(1:10) # [1] 1 2 6 24 120 720 5040 40320 362880 3628800
Comments
Post a Comment