我有一组调查数据,我想生成特定变量的地块,被申请人的国家分类。 该代码我写生成该地块至今:
countries <- isplit(drones, drones$v3)
foreach(country = countries) %dopar% {
png(file = paste(output.exp, "/Histogram of Job Satisfaction in ", country$key[[1]], ".png", sep = ""))
country.df <- data.frame(country) #ggplot2 doesn't appreciate the lists nextElem() produces
ggplot(country.df, aes(x = value.v51)) + geom_histogram()
dev.off()
}
真正奇怪的事情吗? 我可以运行isplit(),设置country <- nextElem(countries)
,然后通过代码不发送的foreach线运行-并获得一个可爱的情节。 如果我发送的foreach,我得到一些空白.png文件。
在此先感谢您的帮助。
我可以肯定地与标准的R做循环,但我真的很想得到一个更好的把握foreach
。