My apologies, I misread your formula. Here is a clearer example anyways: w <- 1:10 N <- length(w) a <- 1 b <- 1 k <- 1:(N-1) w[k+1] <- w[k]*(a/(b+k)) w [1] 1.0000000 0.5000000 0.6666667 0.7500000 0.8000000 0.8333333 0.8571429 [8] 0.8750000 0.8888889 0.9000000
Best, Josh On Fri, Feb 26, 2010 at 7:23 AM, <khaz...@ceremade.dauphine.fr> wrote: > Hello all, > > I want to define a vector like w[k+1]=w[k]*a/(b+k) for k=1,...,N-1 without > use loop. Is it posible to do in R? > > Regards > > khazaei > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > -- Joshua Wiley Senior in Psychology University of California, Riverside http://www.joshuawiley.com/ [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.