Skip to content

Instantly share code, notes, and snippets.

@gghatano
Created September 13, 2014 11:43
Show Gist options
  • Save gghatano/16eaa47c035542bc2197 to your computer and use it in GitHub Desktop.
Save gghatano/16eaa47c035542bc2197 to your computer and use it in GitHub Desktop.
スキあらば並列計算をするおじさん
library(dplyr)
randomwalk2D <- function(){cbind(x=cumsum(rnorm(100)), y=cumsum(rnorm(100)))}
library(foreach)
library(doParallel)
registerDoParallel(detectCores())
res_df = foreach(i = 1:10, .combine = rbind) %dopar%
data.frame(randomwalk2D(), group=LETTERS[i])
res_df %>%
ggplot(aes(x=x, y=y)) +
geom_path( aes(color=group)) +
geom_point(aes(color=group), size=3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment