[R] repeat takes along time

PIKAL Petr petr.pikal at precheza.cz
Wed Oct 24 08:22:52 CEST 2012


Hi

> 
> Hi
> 
> I want help for "repeat" because it takes a long time
> 
> repeat{
> for (i in 1:n){
> probb[i]=sum(Wc[z[,j]>=yb[i]])
> }
> deltab[,b]=rbinom(n,1,probb)
> if(length(which(is.na(deltab[,b])==T))==0){break}
> }
> 
> This code works but takes much computation time.

What is this code supposed to do? It gives an error (see below)

> repeat{
+ for (i in 1:n){
+ probb[i]=sum(Wc[z[,j]>=yb[i]])
+ }
+ deltab[,b]=rbinom(n,1,probb)
+ if(length(which(is.na(deltab[,b])==T))==0){break}
+ }
Error: object 'n' not found
>

PLEASE do read the posting guide http://www.R-project.org/posting-
guide.html
and provide commented, minimal, self-contained, reproducible code.

and some data to test the code.

Anyway, this kind of code shall be implemented probably in other language like C+.

Regards
Petr


> 
> Anyone could help me to find a solution to take a shor time.
> 
> Thanks
> 
> Jorge
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/repeat-
> takes-along-time-tp4647160.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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