Skip to content

Commit 61ae42c

Browse files
author
Data Without Borders
committed
Merge pull request #8 from lmiratrix/luke-work
cleaned up figures
2 parents 7584dae + 6671d75 commit 61ae42c

File tree

2 files changed

+182
-1
lines changed

2 files changed

+182
-1
lines changed

SF_2011/Benetech/R/Q1b_server_growth.R

+28-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ bf$tot.attach = cumsum( bf$public.attachments + bf$private.attachments )
3535

3636

3737
# select some subsample for plotting
38-
pick = round( seq( 1, nrow(bf), length.out=2000 ) )
38+
pick = round( seq( 1, nrow(bf), length.out=4000 ) )
3939
pick = pick[ !duplicated( bf$date.uploaded[ pick ], fromLast=TRUE ) ]
4040

4141
# make the full subsample
@@ -82,6 +82,20 @@ plot.tot = function( bfs ) {
8282
}
8383

8484

85+
plot.tot.from = function( bfs, years ) {
86+
cut = max(bfs$date.uploaded) - years * 365 * 24*60*60
87+
keep = bfs$date.uploaded >= cut
88+
par( mfrow=c(2,2), mar=c(3,3,1,1), mgp=c(2,1,0) )
89+
plot( bfs$date.uploaded[keep], bfs$tot.bull[keep], type="l", xlab="Time", ylab="Total Bulletins" )
90+
plot( bfs$date.uploaded[keep], bfs$totKb[keep]/1024, type="l", xlab="Time", ylab="Total Megabytes")
91+
plot( bfs$date.uploaded[keep], bfs$accounts[keep], type="l", xlab="Time", ylab="Total Number of Distinct Accounts" )
92+
plot( bfs$date.uploaded[keep], bfs$tot.attach[keep], type="l", xlab="Time", ylab="Total Number of Attachments" )
93+
94+
}
95+
96+
97+
98+
8599
# no truncation
86100
plot.deriv = function( bfs ) {
87101
par( mfrow=c(2,2), mar=c(3,3,1,1), mgp=c(2,1,0) )
@@ -102,6 +116,19 @@ plot.deriv.trunc = function( bfs ) {
102116

103117

104118

119+
plot.deriv.from = function( years ) {
120+
cut = max(days) - years * 365 * 24*60*60
121+
keep = days >= cut
122+
par( mfrow=c(2,2), mar=c(3,3,1,1), mgp=c(2,1,0) )
123+
plot( days[keep], bull.per.day[keep], type="l", xlab="Time", ylab="Bulletins Per Day" )
124+
plot( days[keep], kb.per.day[keep]/1024, type="l", xlab="Time", ylab="Megabytes per Day")
125+
plot( days[keep], account.per.day[keep], type="l", xlab="Time", ylab="New Accounts per Day" )
126+
plot( days[keep], attach.per.day[keep], type="l", xlab="Time", ylab="Attachments per Day" )
127+
}
128+
129+
130+
131+
105132
if (FALSE) {
106133

107134
plot.tot( bfs.big )

SF_2011/Benetech/R/Q1btest.Rnw

+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
%
2+
% benetech_report.rnw
3+
%
4+
% Created on 2011-11-05
5+
%
6+
%
7+
\documentclass[xcolor=dvipsnames, 9pt,handout]{beamer}
8+
9+
\newenvironment{code}{\begin{semiverbatim} \begin{footnotesize}}
10+
{\end{footnotesize}\end{semiverbatim}}
11+
12+
\usepackage{graphicx}
13+
\usepackage{amssymb}
14+
\usepackage{amsfonts}
15+
\usepackage{amsmath}
16+
\usepackage{hyperref}
17+
\usepackage{natbib}
18+
\usepackage{color}
19+
\usepackage{pdfsync}
20+
\usepackage{chancery}
21+
% \usepackage{movie15}
22+
\usepackage{pgfpages}
23+
\usepackage{fancyvrb}
24+
\usepackage{colortbl}
25+
% Multipart figures
26+
% \usepackage{subfigure}
27+
28+
% \definecolor{white}{rgb}{255,255,255}
29+
% \definecolor{darkred}{rgb}{0.5,0,0}
30+
% \definecolor{darkgreen}{rgb}{0,0.5,0}
31+
% \definecolor{lightblue}{rgb}{0,0,0.7}
32+
33+
% \hypersetup{colorlinks,
34+
% linkcolor=white,
35+
% filecolor=darkred,
36+
% urlcolor=lightblue,
37+
% citecolor=darkblue}
38+
39+
\usepackage{beamerthemesplit}
40+
\usetheme{Hannover}
41+
\usecolortheme{dove}
42+
\setbeamertemplate{navigation symbols}{}
43+
\setbeamertemplate{itemize items}[triangle]
44+
\setbeamertemplate{enumerate items}[default]
45+
%\setbeameroption{show notes on second screen}
46+
47+
\newcommand{\R}{\mathbb{R}}
48+
\renewcommand{\d}{\mathsf{d}}
49+
\newcommand{\dd}{\partial}
50+
\newcommand{\E}{\mathsf{E}}
51+
\newcommand{\bb}{\mathbf}
52+
53+
\graphicspath{{../images/}}
54+
55+
\title{Martus Usage Report}
56+
\date{\today}
57+
58+
\institute{\includegraphics[width = 5cm]{Benetech-Logo-tag.jpg}}
59+
60+
\begin{document}
61+
62+
% The data frame is called 'benetech'
63+
<<echo=false>>=
64+
#source('load_data.R')
65+
@
66+
67+
\begin{frame}{Cumulative Usage Plots}
68+
69+
\begin{figure}
70+
\begin{center}
71+
72+
<<TotalUsagePlot, fig=TRUE, height=4.2, width=6.5, echo=FALSE>>=
73+
source( "Q1b_server_growth.R" )
74+
plot.tot(bfs.big)
75+
@
76+
\caption{Total usage over time}
77+
\end{center}
78+
\end{figure}
79+
80+
\end{frame}
81+
82+
83+
\begin{frame}{Average Daily Usage Plots}
84+
85+
\begin{figure}
86+
\begin{center}
87+
88+
<<AverageDailyUsagePlot, height=4.2, width=6.5, fig=TRUE, echo=FALSE>>=
89+
plot.deriv(bfs.little)
90+
@
91+
\caption{Daily usage over time}
92+
\end{center}
93+
\end{figure}
94+
95+
\end{frame}
96+
97+
98+
99+
100+
\begin{frame}{Total Usage Plots (Last 3 Years) }
101+
102+
\begin{figure}
103+
\begin{center}
104+
105+
<<TotalUsageThreeYears, fig=TRUE, height=4.2, width=6.5, echo=FALSE>>=
106+
plot.tot.from(bfs.big, 3 )
107+
@
108+
\caption{Total Usage Over Last Three Years}
109+
\end{center}
110+
\end{figure}
111+
112+
Note: as previous slide, but truncated to last three years.
113+
\end{frame}
114+
115+
116+
117+
118+
\begin{frame}{Average Daily Usage Plots (Last 3 Years) }
119+
120+
\begin{figure}
121+
\begin{center}
122+
123+
<<AverageDailyUsagePlotThreeYears, fig=TRUE, height=4.2, width=6.5, echo=FALSE>>=
124+
plot.deriv.from(3)
125+
@
126+
\caption{Average Daily Usage Over Last Three Years}
127+
\end{center}
128+
\end{figure}
129+
130+
Note: as previous slide, but truncated to last three years.
131+
\end{frame}
132+
133+
134+
135+
\begin{frame}{Average Daily Usage Plots (Last 3 Years) }
136+
137+
\begin{figure}
138+
\begin{center}
139+
140+
<<AverageDailyUsagePlotTruncated, fig=TRUE, height=4.2, width=6.5, echo=FALSE>>=
141+
plot.deriv.trunc(bfs.little)
142+
@
143+
\caption{Average Daily Usage Over Last Three Years}
144+
\end{center}
145+
\end{figure}
146+
147+
Note: as previous slide, but truncated to 95\% of values to see typical behavior without extreme outliers.
148+
\end{frame}
149+
150+
151+
152+
153+
154+
\end{document}

0 commit comments

Comments
 (0)