Re: [R] Vectorizing loop

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Tue 11 Oct 2005 - 22:54:42 EST


I don't have anything specific to say. Only the following suggestion:

Try and find out where in the code most of the time is spent. R has nice tools for that. See ?Rprof. If it's runifpoint() and Kest() that are taking most of the computing time, you may not be able to do much better.

Andy

> From: Rainer M. Krug
>
> Sorry
>
> runifpoint() and Kest are from the package spatstat
>
> Rainer
>
> Liaw, Andy wrote:
> > Not unless we know what runifpoint() and Kest() are. AFAIK
> these are not
> > part of base R. If you use functions from add-on packages,
> please state
> > them so as not to leave others guessing. (This is in the
> Posting Guide,
> > which you were asked to read.)
> >
> > Andy
> >
> >
> >>From: Rainer M. Krug
> >>
> >>Hi
> >>
> >>I have the following loop and would like to vectorize it. Any
> >>ideas if
> >>it is possible?
> >>
> >>Thanks,
> >>
> >>Rainer
> >>
> >>Tha Loop:
> >>
> >>for (i in 2:Result$NoSims)
> >>{
> >> ppp <- runifpoint(Result$NoPlants)
> >> K <- Kest(ppp)
> >> Result$LSim[i,] <- sqrt(K$iso / pi) - K$r
> >> CM <- (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1])
> >> Result$SigCM[i] <- sum(CM, na.rm=TRUE)
> >> print(i)
> >> flush.console()
> >>}
>
> ______________________________________________
> R-help@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
>
>



R-help@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 Received on Tue Oct 11 22:58:58 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:40:19 EST