library(rredis) # Get a message sent from Mike's machine. host="192.168.1.65" redisConnect(host="") redisRPush("example1", "Hello from Mike's Mac") # Now send a message back to Mike's Mac redisLPop("example1") cm <- c() for (i in 1:redisLLen("colmeans")) { cm <- c(cm, redisBLPop("colmeans", timeout=10)$colmeans) } library(doRedis) library(itertools) registerDoRedis(queue="ClinicCluster", host=host) numberCols <- 100 x <- matrix(rnorm(1000), ncol=numberCols) cm <- foreach(j=isplitVector(1:numberCols, chunkSize=10), .combine=c) %dopar% { print("thanks for your cycles!") apply(x[, j, drop=FALSE], 2, mean) } # Airline example depDelays <- foreach (airlineYear=1987:1988, .combine=c) %dopar% { # Grab the file. fileName <- paste(airlineYear, ".csv.bz2", sep="") print(paste("Grabbing file", fileName)) system( paste('wget http://stat-computing.org/dataexpo/2009/', fileName, sep="")) print("file downloaded, creating data frame") # Read in first 1000 rows of the the data frame x <- read.csv(bzfile(paste(airlineYear, ".csv.bz2", sep="")), nrows=10000) print("returning result, thanks for the cycles") # Delete the file unlink(fileName) # Return the mean departure delay mean(x$DepDelay, na.rm=TRUE) }