Building a reporting sytem with BREW

13
Building a reporting system with BREW Xavi Guardiola Chief Technology Officer Simpple - Xarxa Sanitària i Social de Santa Tecla @xguardi [email protected]

description

 

Transcript of Building a reporting sytem with BREW

Page 1: Building a reporting sytem with BREW

Building a reporting system withBREW

Xavi GuardiolaChief Technology OfficerSimpple - Xarxa Sanitària i Social de Santa Tecla

@[email protected]

Page 2: Building a reporting sytem with BREW

Datawharehouse

Data analysis

Report template

Report

Enterprise report generation

Report template wizards: Jasper Reports, BIRT, etc.

Report distribution:Web, email.Dynamic reports

Rep Rep Rep

Page 3: Building a reporting sytem with BREW

Enterprise reporting design shortcomings

Poor in-report logic.Not a best practice but most of the times inevitable!

Ugly defaults.Please, check out Tufte books.

Simple plots.Sometimes you need statistical or more complex plots.

Regular users should be able to create their own reports. Really?

Page 4: Building a reporting sytem with BREW

Brew The dumbest example

<% x <- 2 %>Good morning.Today the kilo oranges is priced at <%= x %> euros.

example.brew

Good morning.Today the kilo oranges is priced at 2 euros.

example.txt

R> brew(“example.brew”, “example.txt”)

Page 5: Building a reporting sytem with BREW

Brew Precomputing things before

<% load(“data.Rdata”) %>Good morning.Today the kilo oranges is priced at <%= x %> euros.

example.brew

Good morning.Today the kilo oranges is priced at 2 euros.

example.txt

R> brew(“example.brew”, “example.txt”)

x <- 2save(x, file= “data.Rdata”)

example.R

Page 6: Building a reporting sytem with BREW

Brew Smart templates

<% load(“data.Rdata”) %>Good morning.Today the kilo oranges is priced at <%= x %> euros.<% if x > 1 %>That’s f***ing expensive!<% end %>

example.brew

Good morning.Today the kilo oranges is priced at 2 euros.That’s f***ing expensive!

example.txt

R> brew(“example.brew”, “example.txt”)

x <- 2save(x, file= “data.Rdata”)

example.R

Page 7: Building a reporting sytem with BREW

Brew + latex

\begin{document}Today the kilo oranges $\rightarrow$ <%= x %> euros.\end{document}

example.brew

\begin{document}Today the kilo oranges $\rightarrow$ 2 euros.\end{document}

example.tex

R> brew(“example.brew”, “example.tex”)

R> texi2dvi(“example.tex”, pdf=TRUE)

example.pdf

Today the kilo oranges ! 2 euros.

Page 8: Building a reporting sytem with BREW

The alternative stack

Datawharehouse

Data analysis

Report template

Report

Rep Rep Rep

R script

Brew latex template

Report

Rep Rep Rep

Datawharehouse R selects DB dataRJDBC, RMySQL, etc.

R computes results and plots.

Latex brew template loadsresults and plots and generate template file

PDF report is generated from the tex file

Page 9: Building a reporting sytem with BREW

Report example

Page 10: Building a reporting sytem with BREW

Report example

Page 11: Building a reporting sytem with BREW

Report example

Page 12: Building a reporting sytem with BREW

Brew vs Sweave

\begin{document}

\begin{table}<% for (i in 1:nrow(data)) { -%> <%= data$name[i] %> & <%= data$value[i] %> \\\end{table}

Price is <%= x %>

\begin{figure} \includegraphics{...}\end{figure}

\end{document}

example.brew

\begin{document}

<<Table1, echo=F,results=tex>>=print(xtable(data))@

Price is \Sexpr{x}

<<plot1, echo=F, fig=T>>==print(plot1)@

\end{document}

example.Rnw

Page 13: Building a reporting sytem with BREW

Thanks!