Skip to content
Snippets Groups Projects
Commit 7a162560 authored by William Stonewall Monroe's avatar William Stonewall Monroe
Browse files

added a text file including a series of R instructions to test out parallelism

parent 3f928c36
No related branches found
No related tags found
No related merge requests found
install.packages("plyr")
install.packages("doMC")
library(plyr)
library(doMC)
doMC::registerDoMC(cores=24) # or however many cores you have access to
system.time(ddply(iris, .(Species), function(x) {
Sys.sleep(2)
nrow(x)
}))
# user system elapsed
# 0.005 0.001 6.016
system.time(ddply(iris, .(Species), function(x) {
Sys.sleep(2)
nrow(x)
}, .parallel = TRUE))
# user system elapsed
# 0.018 0.015 2.031
headers <- c("timestamp", "phrase_id", "account_id", "price", "auto")
df <- read.table("./ydata-ysm-advertiser-bids-v1_0.txt")
colnames(df) <- headers
system.time(ddply(df, .(phrase_id, account_id), function(x) {
data.frame(mean=mean(x$price, na.rm=T), median=median(x$price, na.rm=T))
nrow(x)
}))
# user system elapsed
# 42.989 0.734 43.726
system.time(ddply(df, .(phrase_id, account_id), function(x) {
data.frame(mean=mean(x$price, na.rm=T), median=median(x$price, na.rm=T))
nrow(x)
}, .parallel = TRUE))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment