Skip to content

Instantly share code, notes, and snippets.

@wch
Created March 27, 2012 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wch/2213801 to your computer and use it in GitHub Desktop.
Save wch/2213801 to your computer and use it in GitHub Desktop.
Script for loading and processing data on ggplot2 speed
require(RCurl)
require(plyr)
mytsv <- getURL("https://docs.google.com/spreadsheet/pub?key=0AhQ4CGoYYLyvdDd6b2Q5MG9ic2NoQWRPT3dLT0FyUkE&output=txt", ssl.verifypeer = FALSE)
raw <- read.delim(textConnection(mytsv), quote = "", stringsAsFactors = FALSE)
# Process the stuff from dput() on each row
parserow <- function(row) {
d <- eval(parse(text = row[[2]]))
data.frame(
arch = d$ver$arch,
os = d$ver$os,
rver = paste(d$ver$major, d$ver$minor, sep = "."),
time_build = d$time$user.self[2],
time_render = d$time$user.self[3],
time_draw = d$time$user.self[4],
time_total = d$time$user.self[5]
)
}
# Run parserow on each row and add to the raw data frame
dat <- adply(raw, 1, parserow)
# Drop the dput column
dat <- dat[,-2]
dat <- rename(dat, c(
CPU.type="cpu",
Number.of.cores="cores",
Clock.speed="clock",
Other.CPU.information="cpu.other",
Short.description.of.computer="desc",
Computer.Type="type",
Other.notes="other"))
# Shorten description
dat$desc <- substr(dat$desc, 1, 16)
# Keep just some of the columns
d <- dat[,c("arch", "os", "cpu", "cores", "clock", "time_total", "rver", "type", "desc")]
# Sort by time
d <- arrange(d, time_total)
d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment