% \VignetteIndexEntry{ReportingTools shiny} % \VignetteDepends{} % \VignetteKeywords{reprise} % \VignetteKeywords{shiny} % \VignettePackage{ReportingTools} \documentclass[10pt]{article} \usepackage{times} \usepackage{hyperref} \usepackage{Sweave} \textwidth=6.5in \textheight=8.5in \oddsidemargin=-.1in \evensidemargin=-.1in \headheight=-.3in \title{Using ReportingTools within Shiny Applications} \author{Gabriel Becker and Jessica L. Larson} \date{\today} \begin{document} \maketitle \tableofcontents \newpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Introduction} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% A primary strength of \verb@ReportingTools@ is that it provides powerful, customizable facilities for creating rich, interactive (sortable, filterable, pagable, etc.) and aesthetically pleasing HTML tables based on many disparate types of \verb@R@ objects. \verb@shiny@ is a Web application framework developed by RStudio, Inc. which allows the creation, and deployment of Web applications using only \verb@R@ code. Often these Web applications involve the display of \verb@R@ objects or output, but formatting and rendering of complex \verb@R@ objects is not the focus of the \verb@shiny@ framework. Using the techniques in this vignette, \verb@ReportingTools@' formatting and display capabilities, including both the default mechanisms and the full range of customizable behavior, can be incorporated into \verb@shiny@ applications, allowing the creation of powerful Web applications which involve the display of \verb@R@ objects representing complex data and analysis results. This vignette assumes knowledge of the \verb@shiny@ framework. Readers who are not familiar with shiny are encouraged to read the official \verb@shiny@ tutorial \href{http://rstudio.github.com/shiny/tutorial/}{here} before continuing. \begin{figure}[h] \centering \fbox{ \includegraphics[scale = .5]{shiny.png} } \caption{A shiny web application which uses \tt ReportingTools \rm to display R \tt data.frame \rm objects} \end{figure} The example we will discuss in this document, pictured above, gives the viewer the opportunity to choose between three data frames and displays both a summary and a ReportingTools-powered table containing the chosen data. We will discuss in detail only portions of the code specific to the interface between \verb@shiny@ and \verb@ReportingTools@. Full code for the application is included in our package in the inst/examples/shinyexample directory. To run the example, copy the \tt inst/examples/shinyexample/Ui.R \rm and \tt inst/examples/shinyexample/server.R \rm files to your working directory run the following from an R session: <>= library(shiny) myRunApp() @ \section{Changes to ui.R when using ReportingTools} The single largest change to a ui.R file in order to add \verb@ReportingTools@ functionality is that \verb@ReportingTools@' JavaScript and CSS files must be included in the header of the resulting page so that the \verb@ReportingTools@ tables function properly. We define a function \verb@custHeaderPanel@ function which accepts the \verb@title@ and \verb@windowTitle@ arguments accepted by \verb@shiny@'s \verb@headerPanel@ function but also accepts additional arguments \verb@js@ and \verb@css@. These are expected to be character vectors which specify locations of additional Javascript and CSS libraries, respectively. These files are then read and inserted into the header as code in