Re: [R] Building a random walk vector

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

Matthew Wilson <matt <at> overlook.homelinux.net> 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)))

works.

  Ben Bolker



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.