答案 0 :(得分:1)
您可以在innerFun <- function(a=rnorm(10), q=0.5){
quantile(a, probs = q)
}
library(parallel)
bootFun <- function(a=rnorm(10), q=0.5, nperm=10, no_cores = detectCores() - 1){
parFun <- function(x){
set.seed(x)
ai <- sample(a, size=length(a), replace = TRUE)
return(innerFun(a=ai, q=q))
}
ARGS <- list("innerFun", "a", "q", "nperm")
cl <- parallel::makeCluster(no_cores, type="PSOCK")
nn <- split(1:nperm, 1:nperm)
parallel::clusterExport(cl, varlist = ARGS)
res <- parallel::parLapply(cl, nn, parFun)
parallel::stopCluster(cl)
res <- do.call("rbind", res)
return(res)
}
set.seed(1)
res1 <- bootFun(a=rnorm(100), q=0.5, nperm=10, no_cores = detectCores() - 1)
# Error in get(name, envir = envir) : object 'a' not found
添加Java代理,并根据您的操作系统添加以下内容之一:
如果你使用Ubuntu:
Eclipse -> Run Configurations -> Arguments -> vmargument
如果您使用Windows:
-javaagent:"/root/.m2/repository/org/springframework/spring-instrument/4.3.9.RELEASE/spring-instrument-4.3.9.RELEASE.jar"