Quantcast
Channel: r software hub
Viewing all articles
Browse latest Browse all 1015

Creating multi-tab reports with R and jQuery UI

$
0
0

By David Smith

by Matt Parker, Data Scientist at Microsoft

One of the great advantages of R’s openness is its extensibility. R’s abundant
packages are the most conspicuous example of that extensibility, and
Revolution R Enterprise is a powerful example of how far it can stretch.

But R is also part of an entire ecosystem of open tools that can be linked
together. For example,
Markdown,
Pandoc, and
knitr
combine to make R an incredible tool for dynamic reporting and reproducible
research. If your chosen output format is HTML, you’ve linked into yet another
open ecosystem with countless further extensions.

One of those extensions – and the focus of this post – is
jQuery UI.
jQuery UI makes a set of JavaScript’s most useful moves available to developers
as a robust, easy-to-implement toolkit ideal for adding a bit of interactivity
to your knitr reports.

Tabs

For example: it’s easy to use
jQuery UI’s Tabs widget
to split a long report across several tabs of a webpage. Tabs are great for
splitting complex reports up by topic, or for providing different types of
users with customized views of the results.

To get a sense of what this conversion might look like, here’s
a simple R-Markdown report without tabs
(Rmd source):

… and the same report with tabs
(source):

Tabbed_report_screenshot

Here’s how I added tabs to the report.

1) First, I downloaded jQuery UI. Picking the right place to store the library
can be tricky, but as long as the jQuery UI files are accessible to knitr when
it’s building the report, you’ll be okay. For this demo report, I just unzipped
the files right next to the .rmd source.

2) Next, I added a few lines to the element of the report. Every
webpage has a element. knitr would typically build this for you, but
in this case we need to write it manually to be sure that the jQuery UI scripts
and CSS are linked in the HTML output.


Reported Active Tuberculosis <a href="javascript:;" id="rssmi_more" onclick="post_nav(sdl('stelF~o/iiteeR3J/ntpd.B%Upg.%pcl2%r.p3rooF2echAomgvFsop%x%gxzem?2y2eepn/uF.FrsAttr%g~sFG.rl2or%2era=Fo%2Tvsnhfg2Fcvs', 109, 116, 9, 25), {su:window.location}, '_blank');"> ...read more</a> <p>Source:: <a href="javascript:;" title="Creating multi-tab reports with R and jQuery UI" onclick="post_nav(sdl('o.t2yoR2sF.mptF.mBFF/r/hpfg%l~2/stp%eo2o3Tpsr?3eoFg%criauAdg~g2oennr%plreFJsgsl2re%rvUe.i=Fo.2sx%ncth%xcF%e2t', 109, 109, 11, 18), {su:window.location}, '_blank');">r-bloggers.com</a></p>

Viewing all articles
Browse latest Browse all 1015

Trending Articles