I am trying to run pdredge using the following example code, where the data is located at 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)
From this I get these errors:
"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
What am I doing wrong? Thanks.
You forgot to export model's data to the cluster nodes:
clusterExport(clust, "gages")