[R] Repeating
R. Michael Weylandt
michael.weylandt at gmail.com
Mon May 7 16:35:29 CEST 2012
I don't see anything that looks like it should throw an error, but I
haven't tested your code without "data1" and "id" -- you might look at
? replicate() though -- it's designed for these sorts of things. E.g.,
replicate(100, mean(rexp(50)))
gets me a hundred draws of the mean of 50 random exponential variates
(could be done faster here with some matrix tricks, but that's the
idea)
Michael
On Mon, May 7, 2012 at 6:28 AM, efulas <ef_ulas at hotmail.com> wrote:
> By the way, my "for" function is below, I can't find the mistake
>
>
> rand.max.t<- function(n){
> f<-rep(NA,n)
>
> for (i in 1:n) {
> reassign[i]<-matrix(c(sample(id),data1),203,3)
> new.data<-reassign[,1]
> random.cas=reassign[new.data==0,2:3]
> random.con=reassign[new.data==1,2:3]
> f<- list(x=random.cas[,1],y=random.cas[,2])
> ppregion(xl=min(random.cas[,1])-0.0001,xu=max(random.cas[,1])+0.0001,yl=min(random.cas[,2])-0.0001,yu=max(random.cas[,2])+0.0001)
> g <- Kfn(f,0.01)
>
> random.g <- ((g$y)^2)/pi
> }
> random.g
> }
>
> rand.max.t(10)
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Repeating-tp4614371p4614482.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