brand <- as.character(brand.data$name)
mydata <- data.frame(name=as.vector(name.data$name),stringsAsFactors=F)
mydata$brand <- '
for(i in 1:100){
result <- data.frame(brand=character(),loc= numeric(),len=numeric())
parLapply(cl,1:length(brand),function(j){
infor <- regexpr(brand[j],mydata$name[i])
if( infor> 0 ){
result <- rbind(result,data.frame(brand=brand[j],loc= infor,len=nchar(brand[j])))
}
if(nrow(result)>=1){
result <- result[order(result$loc,-result$len),]
mydata$brand[i] <- as.character(result$brand[1])
}
}
)
}
function{}里面有个叫mydata的数据框(data.frame),已经加载到工作空间,为什么执行上面语句总提示:
Error in checkForRemoteErrors(val) :
2 nodes produced errors; first error: object 'mydata' not found
WIndows XP 32bit 代码已经全贴出来了
mydata$brand <- ''开始不赋值,在循环里赋值
mydata$brand[i] <- as.character(result$brand[1])