Skip to content

Instantly share code, notes, and snippets.

@vlandham
Created February 3, 2015 00:02
Show Gist options
  • Save vlandham/4a201ee74702081d651a to your computer and use it in GitHub Desktop.
Save vlandham/4a201ee74702081d651a to your computer and use it in GitHub Desktop.
dplyr start
require('dplyr')
require("ggplot2")
require('reshape2')
data <- read.table("~/Downloads/pp_3_body_bytes.txt")
names(data) <- c('bytes')
big <- filter(data, bytes > 20000)
sub <- filter(data, bytes < 20000)
p <- ggplot(sub, aes(x = bytes))
p + geom_histogram()
data <- read.table("~/Downloads/all_dates.txt")
names(data) <- c('date', 'rec', 'count')
#big <- filter(data, bytes > 20000)
#sub <- filter(data, bytes < 20000)
p <- ggplot(data, aes(x = factor(date, levels = data$date), y = count, fill= rec))
p + geom_bar(stat="identity", position = "dodge")
data <- read.table("~/Downloads/placement_counts.txt")
names(data) <- c('date', 'placement', 'count')
d_melt <- melt(data, c("date", "count"))
pp_3 <- filter(data, placement == "placement%5D=PP_3")
pp_4 <- filter(data, placement == "placement%5D=PP_4")
alongside <- merge(pp_3, pp_4, by = "date", all = TRUE, sort = FALSE, suffixes = c(".pp_3", ".pp_4"))
alongside$pp4_ratio <- alongside[,"count.pp_4"] / alongside[,"count.pp_3"]
alongside <- filter(alongside, count.pp_4 > 60000)
by_placement = data %>% group_by('placement')
p <- ggplot(data, aes(x = factor(date, levels = data$date), y = count, fill= placement))
p + geom_bar(stat="identity", position = "dodge")
p <- ggplot(alongside, aes(x = factor(date, levels = data$date), y = pp4_ratio))
p + geom_bar(stat="identity", position = "dodge")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment