Fast prototyping of analytic scripts.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Fast Analytics

The Fast Analytics packages is a tool for creating skeleton reports of standard formatted plots. Instead of functions that output plots, this package write the code to generate the listed plots, and necessary data transformations, to a file that can then be edited and run. Often we want the same plot as previous analysis but with some slight adjustments, with single-purpose plotting functions it is difficult to adjust for the specific use cases without altering the function itself. By writing the plotting code to an analysis script the plot can be tweaked, run, and source controlled for each specific analysis.

If latexmk and texlive-full are available on the system the flag tex = TRUE can be set to render the auto-generated figures into a Beamer slide deck. It will default to using the RootTeX if installed and should fall back to the Beamer default template if it is not available.


There is a dependency on my utilities package. To install both:


Example call:

skeleton("whales.R", 2588,
         list(downloadTimeSeries, uploadTimeSeries,
              downloadBoxPlot, uploadBoxPlot,
              twilioFailureMap, m2mFailureMap),
         username = 'michael.hutchins', run = TRUE)


You can view the R script, whales.R, and the TeX file, auto_whales2588.tex, in the sample folders. The resulting images and PDF report are available on fileshare01:Analytics/AnalyticsTeam/Michael/fastAnalyticsSample/. Both the sample and the PDF may or may not be up to date with the latest version of the package, I will try to keep them in sync as new features and adjustments are made.


For more on using LaTeX/Beamer take a look at my Beamer Tutorial.

Writing New Plots

New plots need to have no input variables and output a list of names strings with at least one of the fields:

  1. data - The data pull function required to get the data
  2. process - Any additional processing functions or commands
  3. plot - The text used to make the plotting function
  4. save - The basename of the save file (no path, .png or appended csid value)

Here is a template that can be used for making new plots:

#' Name of the Plot
#' Plot description
#' @return Returns standard fast-analysis structured list
#' @family skeletonPlots
#' @export
boxPlot <- function() {

    save <- 'box_plot'
    data <- pullTestSummary()
    plot <- "
#### Plot Title
plt <- ggplot(data, aes(x = carrier,
                        y = dsd_effective_download_test_speed,
                        fill = carrier)) +
    geom_boxplot(notch = TRUE) +
    scale_fill_root() +
    theme_root() +
    ## Append a line for saving the plot in the standard format
    plot <- paste(plot,
                  sep = "")
    output <- list(data = data,
                   plot = plot,
                   save = save)