Successfully reported this slideshow.

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Related Audiobooks

Free with a 14 day trial from Scribd

See all

Building a reporting sytem with BREW

  1. 1. Building a reporting system with BREW Xavi Guardiola Chief Technology Officer Simpple - Xarxa Sanitària i Social de Santa Tecla xavier.guardiola@simpple.com @xguardi
  2. 2. Enterprise report generation Datawharehouse Data analysis Report template wizards: Report template Jasper Reports, BIRT, etc. Report Report distribution: Rep Rep Rep Web, email. Dynamic reports
  3. 3. 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?
  4. 4. Brew The dumbest example example.brew <% x <- 2 %> Good morning. Today the kilo oranges is priced at <%= x %> euros. R> brew(“example.brew”, “example.txt”) example.txt Good morning. Today the kilo oranges is priced at 2 euros.
  5. 5. Brew Precomputing things before example.R x <- 2 save(x, file= “data.Rdata”) example.brew <% load(“data.Rdata”) %> Good morning. Today the kilo oranges is priced at <%= x %> euros. R> brew(“example.brew”, “example.txt”) example.txt Good morning. Today the kilo oranges is priced at 2 euros.
  6. 6. Brew Smart templates example.R x <- 2 save(x, file= “data.Rdata”) example.brew <% load(“data.Rdata”) %> Good morning. Today the kilo oranges is priced at <%= x %> euros. <% if x > 1 %> That’s f***ing expensive! <% end %> R> brew(“example.brew”, “example.txt”) example.txt Good morning. Today the kilo oranges is priced at 2 euros. That’s f***ing expensive!
  7. 7. Brew + latex example.brew begin{document} Today the kilo oranges $rightarrow$ <%= x %> euros. end{document} R> brew(“example.brew”, “example.tex”) example.tex begin{document} Today the kilo oranges $rightarrow$ 2 euros. end{document} R> texi2dvi(“example.tex”, pdf=TRUE) example.pdf Today the kilo oranges ! 2 euros.
  8. 8. The alternative stack R selects DB data Datawharehouse Datawharehouse RJDBC, RMySQL, etc. R computes results and Data analysis R script plots. Latex brew template loads Report template Brew latex template results and plots and generate template file PDF report is generated Report Report from the tex file Rep Rep Rep Rep Rep Rep
  9. 9. Report example
  10. 10. Report example
  11. 11. Report example
  12. 12. Brew vs Sweave example.brew example.Rnw begin{document} begin{document} begin{table} <<Table1, echo=F,results=tex>>= <% for (i in 1:nrow(data)) { -%> print(xtable(data)) <%= data$name[i] %> & @ <%= data$value[i] %> end{table} Price is Sexpr{x} Price is <%= x %> <<plot1, echo=F, fig=T>>== print(plot1) begin{figure} @ includegraphics{...} end{figure} end{document} end{document}
  13. 13. Thanks!

×