[R] Vectorizing loop
Rainer M. Krug
RKrug at sun.ac.za
Mon Oct 10 15:12:05 CEST 2005
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()
>>}
More information about the R-help
mailing list