0
r에 루프를 쓰고 있습니다. 마지막 줄의 오류 메시지는 입니다. "match.names 오류 (clabs, names (xi)) : 이름 이전 이름과 일치하지 않습니다. " 마지막 줄은 모든 루프 라운드마다 모든 행 값을 유지하려고합니다. 모두에게 감사드립니다. 당신이 for (id in unique_index)
루프를 시작하기 전에루프의 이전 행에 모든 행을 추가하는 방법 R
a = 20 # resample times
for (id in unique_index){
jeep_id <- jeep_boot[which(jeep$index == id),]
#sample_size is 0.8 of the whole data
sample_size <- floor((0.8)*length(jeep_id$PR))
#bootstrap sample means
samplemeans = rep(NA, a)
for (i in 1:a) {
bootsample.i = sample(jeep_id$PR, sample_size, replace=T)
samplemeans[i] = mean(bootsample.i)
}
#combine mean of 20 sample means and stand dieviation of sample means to be one row
bootresult_id <- cbind(id, mean(samplemeans), sd(samplemeans))
#retain every row value for each round looping
bootresult <- rbind(bootresult, bootresult_id)
}
작업 할 몇 가지 예제 데이터 (및 예상되는 결과)를 제공하는 것을 고려해보십시오. 그렇게함으로써 더 많은 반응을 얻을 수 있습니다. 테스트 용 예제 데이터를 만들 수 있습니다. 그러나 실제 데이터 집합을 모방하지 않을 수 있습니다. – akrun