Re: [R] Building a random walk vector

From: Ben Bolker <>
Date: Fri 04 Aug 2006 - 11:27:22 EST

Matthew Wilson <matt <at>> writes:

> I'm studying R in my free time. I want to build a vector where each
> element is equal to the element before it in the sequence plus some
> random tweak.

  You will probably get many answers to this, but I think

vec <- 100+c(0,cumsum(runif(49,-2,2)))


  Ben Bolker mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri Aug 04 17:47:32 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 04 Aug 2006 - 18:17:28 EST.

Mailing list information is available at Please read the posting guide before posting to the list.