On 26.02.2010 16:23, 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?

Sure:


wMake <- function(w, a, b, n){
        w * (a^(0:(n-1))) / cumprod(c(1, (b+1):(b+n-1)))
}

wMake(w=1, a=2, b=3, n=10)

Uwe Ligges




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
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
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.

Reply via email to