0

我正在尝试使用以下示例代码运行 pdredge,其中数据位于 https://github.com/aditibhaskar/help/blob/master/gages_urbanizing_and_ref_with_trends_cut_to_20years_2018-12-02.Rdata

library(MuMIn)
require(snow)
require(parallel)
variable.list <- c("log(hden_change_divided_by_hdenStart)", "hden_peak_change", "DRAIN_SQKM", "PPTAVG_BASIN", "SNOW_PCT_PRECIP", "log(HIRES_LENTIC_PCT)", "FRAGUN_BASIN",  "BFI_AVE", "CLAYAVE", "WTDEPAVE", "AWCAVE", "RD_STR_INTERS", "RIP800_FOREST", "BAS_COMPACTNESS", "STREAMS_KM_SQ_KM", "RRMEAN", "SLOPE_PCT", "PCT_1ST_ORDER", "FRESHW_WITHDRAWAL")

y.365 <- lm(paste0("(SlopePct.365 - Ref1.SlopePct.365) ~", paste(variable.list, collapse="+")), data=gages)

options(na.action = "na.fail")

no_cores <- detectCores() - 1
cl <- makeCluster(no_cores)

clusterType <- if(length(find.package("snow", quiet = TRUE))) "SOCK" else "PSOCK"
clust <- try(makeCluster(getOption("cl.cores", no_cores), type = clusterType))
dredge.365 <- pdredge(y.365, rank="AICc", trace=2, cluster=clust)

从这里我得到这些错误:

"2097152: In is.data.frame(data): 
object 'gages' not found (model 2097151 skipped)
Error in pdredge(y.365, rank="AICc", trace=2, cluster=clust) : 
the result is empty

我究竟做错了什么?谢谢。

4

1 回答 1

1

您忘记将模型的数据导出到集群节点:

clusterExport(clust, "gages")
于 2018-12-05T03:55:39.783 回答