[R] ifelse question
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Tue Dec 12 22:10:38 CET 2006
jropers at freesurf.fr wrote:
> What is puzzling me is that rnorm(1) is only evaluated *twice*, one time
> for each branch, with only 2 different random deviates, instead of
> giving ten different random deviates. y1 has indeed 10 values but with
> only 2 different ones.
>
I find it more puzzling why you expect that ifelse, a function of three
vector arguments, would cause its input arguments to be reevaluated for
every element of the result.
> I would like to have rnorm be evaluated for each row and collect ten
> *different* random deviates.
>
> y1
> [1] 0.4087172 0.7707796 0.4087172 0.4087172 0.7707796 0.4087172 0.4087172
> [8] 0.7707796 0.7707796 0.4087172
>
>
> Thanks.
>
> Jacques.
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list