R의 병렬 패키지에서 작동하도록 일부 코드를 가져 오는 데 문제가 있습니다. R 2.15를 사용하고 있습니다.R 병렬 S4 클래스 클러스터 오류
가 여기에 파일 다음이 들어 'animal.R'을 가지고 ... 간단한 예입니다 : 내 R 단자에,
# animal.R
setClass("Animal", representation(species = "character", legs = "numeric"))
##Define some Animal methods
setGeneric("count",function(x) standardGeneric("count"))
setMethod("count", "Animal", function(x) { [email protected]})
setGeneric("countAfterChopping",function(x) standardGeneric("countAfterChopping"))
setMethod("countAfterChopping", "Animal", function(x) { [email protected] <- [email protected]; [email protected]})
그럼, 실행
library(parallel)
source('animal.R')
시작 두 노드의 로컬 클러스터 :
cl <- makeCluster(rep('localhost', 2))
동물 클래스에 대한 클러스터 노드 알려주기 :
# This works
parSapply(cl, list(daisy, fred), count)
# This doesn't...
parSapply(cl, list(daisy, fred), countAfterChopping)
정지 클러스터 :
clusterEvalQ(cl, parse('animal.R'))
그런 다음 클러스터의 일부 코드 실행
이stopCluster(cl)
parSapply에 대한 첫 번째 호출이 예상 작품으로,하지만 두 번째는이 오류가 발생합니다 :
Error in checkForRemoteErrors(val) :
2 nodes produced errors; first error: "Animal" is not a defined class
아이디어가 있습니까? parSapply에 대한 두 번째 호출이 작동하지 않는 이유는 무엇입니까?
'clusterEvalQ (CL, 평가 (구문 분석 ('animal.R는 ')))'또는 스크립트를 소스로 사용하십시오. 그게 속임수 였어? – BenBarnes
아, 그래 ... 그 트릭을하는 것 같습니다. 매우 감사합니다! – Ash