##    Package Needed
library(fields)

## Assumptions
set.seed(123)
nsim<-5
p<-2

##    Generate Random Matrix G
G <- matrix(runif(p*nsim),nsim,p)

##    Set Empty Matraces dmax and dmin
dmax<- matrix(data=NA,nrow=nsim,ncol=p)
dmin<- matrix(data=NA,nrow=nsim,ncol=p)

## Loop to Fill dmax and dmin
for(i in 1:nsim) {

dmax[i]<- max(rdist(G[i,,drop=FALSE],G))
dmin[i]<- min(rdist(G[i,,drop=FALSE],G[-i,])) }

I filled the dmax and dmin with the distance values I calculated, but what I really want to fill them with are the rows in G. What should I do? I tried "which" function but it did not work. Thank you in advance!!!!




qqh5011
	[[alternative HTML version deleted]]

