Skip to content

Instantly share code, notes, and snippets.

@araastat
Created November 12, 2013 18:19
Show Gist options
  • Save araastat/7436021 to your computer and use it in GitHub Desktop.
Save araastat/7436021 to your computer and use it in GitHub Desktop.
setwd('~/Downloads')
dat <- read.csv('VennDiagrams2-data.csv', stringsAsFactors=F)
for(u in c('visited','joined')){
dat[[u]] <- as.Date(dat[[u]])
}
library(plyr)
library(reshape2)
library(chron)
dat$monthly = paste(months(as.chron(dat$visited)), years(as.chron(dat$visited)))
visits = ddply(dat, ~monthly+groupName, summarise, count=length(member_id))
visits <- transform(visits, monthly = as.Date(paste('1',monthly), format='%d %b %Y'), groupName=as.factor(groupName))
library(ggplot2)
ggplot(subset(visits, monthly >= as.Date('2013-01-01')),
aes(x=monthly, y=count,
group=factor(groupName), color=factor(groupName)))+
geom_line()+
labs(x='', y='Number of visits',color='Program')+
ggtitle('2013') +
theme(legend.position=c(0.2, 0.65))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment