[R] question to make a vector without loop
Phil Spector
spector at stat.berkeley.edu
Fri Feb 26 19:12:19 CET 2010
Khazaei -
I think
mapply(function(x,ind)x * a / (b + ind),c(NA,w),c(NA,1:length(w)))
does what you want, but since you didn't include a reproducible
example, I can't tell for sure.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spector at stat.berkeley.edu
On Fri, 26 Feb 2010, khazaei at 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 at 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.
>
More information about the R-help
mailing list