-2
저는 프로그래밍의 초보자이고 25 개의 셀 모두를 최소 거리 "d"로 구분하여 샘플링하려고합니다. 내가 제안을 주셔서 감사합니다 정말 거라고r에있는 거리 조건을 충족하는 샘플 N 셀
b=c() # vector to store the selected cells
b[1]=sample(a,1) # randomly sampling the first cell from my landscape
x=c()
for (i in 1:24){
b2=sample(a,1) #propose a candidate cell
for(j in 1:i){
if (DIJ[b[j],b2]>=d){ #check if the distance between the proposed and ALL the
x[i]=1 chosen
#cells meets the distance, where DIJ is a distance matrix
} assign 1 if it does, 0 otherwise
else{x[i]=0
}}
while(sum(x)==i){ #If the sum equals i, then the proposed meets the requirement
b2=b[i+1] against all the cells, otherwise start again with a new
}} proposal
코드 작업이 조각을해야한다.
알레한드로
A [재현성 예]를 입력 해주세요 (http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Thomas
샘플 데이터주세요! – Metrics
샘플 하나의 셀. 샘플링 된 셀과 너무 가까운 셀을 제거하십시오. 샘플 두 번째 셀. 마지막 두 단계를 25 번 반복하십시오. –