我在R中有一段代码。每次在集群上运行它时,我都会得到一个答案,列的顺序不同。 (在我的笔记本电脑上似乎还可以)。如果我对列进行排序以使它们具有相同的顺序,答案是相同的,那么唯一的问题就是列的排序。
NNs_loc_year <- Reduce(cbind,
split(NNs_loc_year,
rep(1:n_neighbors, each=(nrow(NNs_loc_year)/n_neighbors)))) %>%
data.table()
# rename columns
NN_dist <- NN_dist %>% data.table()
names(NN_dist) <- paste0("NN_", c(1:n_neighbors))
names(NNs_loc_year) <- paste0(names(NNs_loc_year), paste0("_NN_", rep(1:n_neighbors, each=2)))
NN_chi <- pchi(as.vector(NN_list$nn.dist), PCs)
NN_sigma <- qchi(NN_chi, 1)
NN_sigma_df = Reduce(cbind,
split(NN_sigma,
rep(1:n_neighbors, each=(length(NN_sigma)/n_neighbors)))) %>%
data.table()
names(NN_sigma_df) <- paste0("sigma_NN_", c(1:n_neighbors))
NN_dist_tb = rbind(NN_dist_tb, NN_dist)
NNs_loc_year_tb = rbind(NNs_loc_year_tb, NNs_loc_year)
NN_sigma_tb = rbind(NN_sigma_tb, NN_sigma_df)}