我怎样才能使这个数据框的值逐渐增加。前任。第二个等于第一个+第二个以此类推,为连续时间

How can I make the values ​of this dataframe add progressively. Ex. the second is equal to the first + second and so on, as continuous time

我的代码是这样写的:

HoraLLamadaSimulado2 <- function(n = 50)
{
  tiempodellamada <- 0
  x <- 1
  HORA <- 0
  vec1 <- data.frame()
  while (x < n)
  {
    tiempoentrellamada <- (runif(n, 1000, 1010))
    LLX <- tiempoentrellamada
    HORA <- as.POSIXct(LLX, origin = "2019-01-01", tz = "GMT")
    #HORA <- HORA + tiempoentrellamada
    vec1 <- data.frame(HORA)
    x <- x + 1
  }
  return(vec1)
}
HoraLLamadaSimulado2()

这就是我得到的。即均匀分布50次。我无法计算连续时间的总和。

霍拉 2019-01-01 00:16:46
2019-01-01 00:16:46
2019-01-01 00:16:43
2019-01-01 00:16:47
2019-01-01 00:16:47
2019-01-01 00:16:47
2019-01-01 00:16:47
2019-01-01 00:16:48
2019-01-01 00:16:48
2019-01-01 00:16:43

cumsum的使用情况如何:

set.seed(42)
as.POSIXct(cumsum(runif(10, 1000, 1010)), origin = "2019-01-01")
#  [1] "2018-12-31 16:16:49 PST" "2018-12-31 16:33:38 PST"
#  [3] "2018-12-31 16:50:21 PST" "2018-12-31 17:07:09 PST"
#  [5] "2018-12-31 17:23:56 PST" "2018-12-31 17:40:41 PST"
#  [7] "2018-12-31 17:57:28 PST" "2018-12-31 18:14:10 PST"
#  [9] "2018-12-31 18:30:56 PST" "2018-12-31 18:47:43 PST"