-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnew_repos.R
52 lines (39 loc) · 1.94 KB
/
new_repos.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
setwd('/home/git/githubdata/')
require('ggplot2')
require(xts)
timeline<-as.matrix(read.table('new_repos.csv',sep=',',header=T))
tmp<-xts(vector(length=NROW(timeline)),order.by=as.POSIXct(strftime(timeline[,1],'%Y-%m-%d %H:%M:%S')))
tmp[,1]=1
timeline=aggregate((tmp[,1]),list(factor(format(index(tmp),'%Y%m%d%H'))),sum)
tmp=data.frame(year=substr(as.character(index(timeline)),1,4),hour=substr(as.character(index(timeline)),9,10),count=(as.numeric(timeline)))
years = subset(tmp,tmp$year=='2012')
res = data.frame(aggregate(years$count,list(years$hour),median),
#sd=aggregate(years$count,list(years$hour),sd)[,2],
year=2012)
years = subset(tmp,tmp$year=='2011')
res = rbind(res, data.frame(aggregate(years$count,list(years$hour),median),
#sd=aggregate(years$count,list(years$hour),sd)[,2],
year=2011))
years = subset(tmp,tmp$year=='2010')
res = rbind(res, data.frame(aggregate(years$count,list(years$hour),median),
#sd=aggregate(years$count,list(years$hour),sd)[,2],
year=2010))
years = subset(tmp,tmp$year=='2009')
res = rbind(res, data.frame(aggregate(years$count,list(years$hour),median),
#sd=aggregate(years$count,list(years$hour),sd)[,2],
year=2009))
years = subset(tmp,tmp$year=='2008')
res = rbind(res, data.frame(aggregate(years$count,list(years$hour),median),
#sd=aggregate(years$count,list(years$hour),sd)[,2],
year=2008))
colnames(res)=c('hour','median','year')
png('new_repos.png',width=550)
####log plot######
ggplot(res,aes(hour,log(median)))+
geom_smooth(aes(group=year,colour=factor(year)),alpha=0.3,size=2)+
scale_color_brewer(name='Year',palette="Set1")+xlab('Hour')+ylab('Median')
dev.off()
#####normal plot####
ggplot(res,aes(hour,median))+
geom_smooth(aes(group=year,colour=factor(year)),alpha=0.3,size=2)+
scale_color_brewer(name='Year',palette="Set1")+xlab('Hour')+ylab('Median')