You are currently browsing the monthly archive for June 2014.

Shiny v0.10 comes with a quick, handy guide. Use the Shiny cheat sheet as a quick reference for building Shiny apps. The cheat sheet will guide you from structuring your app, to writing a reactive foundation with server.R, to laying out and deploying your app.

 

cheatsheet

 

You can find the Shiny cheat sheet along with many more resources for using Shiny at the Shiny Dev Center, shiny.rstudio.com.

(p.s. Visit the RStudio booth at useR! today for a free hard copy of the cheat sheet.)

The R User Conference 2014 is coming up fast in Los Angeles!

RStudio will be there in force to share the latest enhancements to shiny, ggvis, knitr, dplyr. R markdown, packrat and more.  Here’s a quick snapshot of our scheduled sessions. We hope to see you in as many of them as you can attend!

Monday, June 30

Morning Tutorials

  • Interactive graphics with ggvis - Winston Chang
  • Dynamic Documents with R and knitr – Yihui Xie

Afternoon Tutorials

  • Data manipulation with dplyr – Hadley Wickham
  • Interactive data display with Shiny and R – Garrett Grolemund

Tuesday, July 1

Session 1 10:30 Room – Palisades
ggvis: Interactive graphics in R – Winston Chang

Session 2 13:00 Room – Palisades
Shiny: R made interactive – Joe Cheng

Session 3 16:00 Room – Palisades
dplyr: a grammar of data manipulation – Hadley Wickham

Wednesday, July 2

Session 5 16.00 Room – Palisades
Packrat – A Dependency Management System for R – J.J. Allaire

Thursday, July 3

Session 6 10:00 Room – Palisades
The Next Generation of R Markdown – J.J. Allaire
Knitr Ninja – Yihui Xie
Embedding Shiny Apps in R Markdown documents – Garrett Grolemund

Every Day

Don’t miss our table in the exhibition area during the conference. Come talk to us about your plans for R and learn how RStudio Server Pro and Shiny Server Pro can provide enterprise-ready support and scalability for your RStudio IDE and Shiny deployments.

Our first public release of ggvis, version 0.3, is now available on CRAN. What is ggvis? It’s a new package for data visualization. Like ggplot2, it is built on concepts from the grammar of graphics, but it also adds interactivity, a new data pipeline, and it renders in a web browser. Our goal is to make an interface that’s flexible, so that you can compose new kinds of visualizations, yet simple, so that it’s accessible to all R users.

Update: there was an issue affecting interactive plots in version 0.3. Version 0.3.0.1 fixes the issue. The updated source package is now on CRAN, and Windows and Mac binary packages will be available shortly.

ggvis_movies

ggvis integrates with Shiny, so you can use dynamic, interactive ggvis graphics in Shiny applications. We hope that the combination of ggvis and Shiny will make it easy for you to create applications for interactive data exploration and presentation. ggvis plots are inherently reactive and they render in the browser, so they can take advantage of the capabilities provided by modern web browsers. You can use Shiny’s interactive components for interactivity as well as more direct forms of interaction with the plot, such as hovering, clicking, and brushing.

ggvis works seamlessly with R Markdown v2 and interactive documents, so you can easily add interactive graphics to your R Markdown documents:

shiny-doc-ggvis  ggvis_density

And don’t worry — ggvis isn’t only meant to be used with Shiny and interactive documents. Because the RStudio IDE is also a web browser, ggvis plots can display in the IDE, like any other R graphics:

ggvis in RStudio IDE

There’s much more to come with ggvis. To learn more, visit the ggvis website.

Please note that ggvis is still young, and lacks a number of important features from ggplot2. But we’re working hard on ggvis and expect many improvements in the months to come.

Shiny 0.10 is now available on CRAN.

Interactive documents

In this release, the biggest changes were under the hood to support the creation of interactive documents. If you haven’t had a chance to check out interactive documents, we really encourage you to do so—it may be the easiest way to learn Shiny.

New layout functions

Three new functions—flowLayout(), splitLayout(), and inputPanel()—were added for putting UI elements side by side.

  • flowPanel() lays out its children in a left-to-right, top-to-bottom arrangement.
  • splitLayout() evenly divides its horizontal space among its children (or unevenly divides if cellWidths argument is provided).
  • inputPanel() is like flowPanel(), but with a light grey background, and is intended for encapsulating small input controls wherever vertical space is at a premium.

A new logical argument inline was also added to checkboxGroupInput() and radioButtons() to arrange check boxes and radio buttons horizontally.

Custom validation error messages

Sometimes you don’t want your reactive expressions or output renderers in server.R to proceed unless certain input conditions are satisfied, e.g. a select input value has been chosen, or a sensible combination of inputs has been provided. In these cases, you might want to stop the render function quietly, or you might want to give the user a custom message. In shiny 0.10.0, we introduced the functions validate() and need() which you can use to enforce validation conditions. This won’t be the last word on input validation in Shiny, but it should be a lot safer and more convenient than how most of us have been doing it.

See the article Write error messages for your UI with validate for details and examples.

Sever-side processing for Selectize input

In the previous release of Shiny, we added support for Selectize, a powerful select box widget. At that time, our implementation passed all of the data to the web page and used JavaScript to do any paging, filtering, and sorting. It worked great for small numbers of items but didn’t scale well beyond a few thousand items.

For Shiny 0.10, we greatly improved the performance of our existing client-side Selectize binding, but also added a new mode that allows the paging, filtering, and sorting to all happen on the server. Only the results that are actually displayed are downloaded to the client. This approach works well for hundreds of thousands or millions of rows.

For more details and examples, see the article Using selectize input on shiny.rstudio.com.

htmltools

We also split off Shiny’s HTML generating library (tags and friends) into a separate htmltools package. If you’re writing a package that needs to generate HTML programmatically, it’s far easier and safer to use htmltools than to paste HTML strings together yourself. We’ll have more to share about htmltools in the months to come.

Other changes

  • New actionLink() input control: behaves like actionButton() but looks like a link
  • renderPlot() now calls print() on its result if it’s visible–no more explicit print() required for ggplot2
  • Sliders and select boxes now use a fixed horizontal size instead of filling up all available horizontal space; pass width="100%" if you need the old behavior
  • The session object that can be passed into a server function is now documented: see ?session
  • New reactive domains feature makes it easy to get callbacks when the current session ends, without having to pass session everywhere
  • Thanks to reactive domains, by default, observers now automatically stop executing when the Shiny session that created them ends
  • shinyUI and shinyServer

For the full list, you can take a look at the NEWS file. Please let us know if you have any comments or questions.

R Markdown’s new interactive documents provide a quick, light-weight way to use Shiny. An interactive document embeds Shiny elements in an R Markdown report. The report becomes “live”, a choose your own adventure that readers can control and explore. Interactive documents are easy to create and easy to share.

Create an interactive document

To create an interactive document use RStudio to create a new R Markdown file, choose the Shiny document template, then click “Run Document” to show a preview:


storms.002

Embed R code chunks in your report where you like. Interactive documents use the same syntax as R Markdown and knitr. Set echo = FALSE. Your reader won’t see the code, just its results.

 

  storms2.001

Include Shiny widgets and outputs in your code chunks. R Markdown will insert the widgets directly into your final document. When a reader toggles a widget, the parts of the document that depend on it will update instantly.

 storms.003

That’s it! No extra files are needed.

Note that in order to use interactive documents you should be running the latest version of RStudio (v0.98.932 or higher). Alternatively if you are not using RStudio be sure to follow the directions here to install all of the required components.

Share your document

Interactive documents can be run locally on the desktop or be deployed Shiny Server v1.2 or ShinyApps just like any other Shiny application. See the RMarkdown v2 website for more details on deploying interactive documents.

Use pre-packaged tools

Interactive documents make it easy to insert powerful tools into a report. For example, you can insert a kmeans clustering tool into your document with one line of code, as below. kmeans_cluster is a widget built from a Shiny app and intended for use in interactive documents.

storms.004

You can build your own widgets with shinyApp, a new function that repackages Shiny apps as functions. shinyApp is easy to use. Its first argument takes the code that appears in an app’s ui.R file. The second argument takes the code that appears in the app’s server.R file. The source of kmeans_cluster reveals how simple this is.

Be a hero

Ready to be a hero? You can use the `shinyApp` function to make out of the box widgets that students, teachers, and data scientists will use everyday. Widgets can

  • fit models
  • compare distributions
  • visualize data
  • demonstrate teaching examples
  • act as quizzes or multiple choice questions
  • and more

These widgets are not made yet, they are low hanging fruit for any Shiny developer. If you know how to program with Shiny (or want to learn), and would like to make your mark on R, consider authoring a package that makes widgets available for interactive documents.

Get started!

To learn more about interactive documents visit http://rmarkdown.rstudio.com/authoring_shiny.html.

 

People rarely agree on a best authoring tool or language. Some people cannot live without \LaTeX{} because of the beauty and quality of its PDF output. Some \feel{} \uncomfortable{} \with{} \backslashes{}, and would rather live in another World Word. We have also witnessed the popularity of Markdown, an incredibly simple language (seriously? a LANGUAGE?) that has made reproducible research much easier.

Thinking of all these tools and languages, every developer will dream about “One ring to rule them all“. \section{}, <h1></h1>, ===, #, … Why cannot we write the first-level section header in a single way? Yes, we are aware of the danger of “adding yet another so-called universal standard that covers all the previous standards”. However, we believe Pandoc has done a fairly good job in terms of “yet another Markdown standard”. Standing on the shoulders of Pandoc, today we are excited to announce the second episode of our journey into the development of the tools for authoring dynamic documents:

The Return of R Markdown!

The R package markdown (plus knitr) was our first version of R Markdown. The primary output format was HTML, which certainly could not satisfy all users in the World Word. It did not have features like citations, footnotes, or metadata (title, author, and date, etc), either. When we were asked how one could convert Markdown to PDF/Word, we used to tell users to try Pandoc. The problem is that Pandoc’s great power comes with a lot of command line options (more than 70), and knitr has the same problem of too many options. That is why we created the second generation of R Markdown, represented by the rmarkdown package, to provide reasonably good defaults and an R-friendly interface to customize Pandoc options.

The new version of RStudio (v0.98.932) includes everything you need to use R Markdown v2 (including pandoc and the rmarkdown package). If you are not using RStudio you can install rmarkdown and pandoc separately as described here. To get started with a “Hello Word” example, simply click the menu File -> New File -> R Markdown in RStudio IDE. You can choose the output format from the drop-down menu on the toolbar.

R Markdown Formats

The built-in output formats include HTML, LaTeX/PDF, Word, Beamer slides, HTML5 presentations, and so on. Pandoc’s Markdown allows us to write richer content such as tables, citations, and footnotes. For power users who understand LaTeX/HTML, you can even embed raw LaTeX/HTML code in Markdown, and Pandoc is smart enough to process these raw fragments. If you cannot remember the possible options for a certain output format in the YAML metadata (data between --- and --- in the beginning of a document), you can use the Settings button on the toolbar.

Extensive documentation for R Markdown v2 and all of it’s supported output formats are available on the new R Markdown website at http://rmarkdown.rstudio.com.

We understand users will never be satisfied by our default templates, regardless of how hard we try to make them appealing. The rmarkdown package is fully customizable and extensible in the sense that you can define your custom templates and output formats. You want to contribute an article to The R Journal, or JSS (Journal of Statistical Software), but prefer writing in Markdown instead of LaTeX? No problem! Pandoc also supports many other output formats, and you want EPUB books, or a different type of HTML5 slides? No problem! Not satisfied with one single static output document? You can embed interactive widgets into R Markdown documents as well! Let there be Shiny! The more you learn about rmarkdown and Pandoc, the more freedom you will get.

For a brief video introduction, you may watch the talk below (jump to 18:30 if you only want to see the demos):

The rmarkdown package is open-source (GPL-3) and is both included in the RStudio IDE and available on GitHub. The package is not on CRAN yet, but will be there as soon as we make all the improvements requested by early users.

To clarify the relationship between rmarkdown and RStudio IDE, our IDE is absolutely not the only way to compile R Markdown documents. You are free to call functions in rmarkdown in any environment. Please check out the R package documentation, in particular, the render() function in rmarkdown.

Please let us know if you have any questions or comments, and your feedback is greatly appreciated. We hope you will enjoy R Markdown v2.

Keep Calm and Markdown

Today we’re very pleased to announce a new version of RStudio (v0.98.932) which is available for download now. New features in this release include:

  • A next generation implementation of R Markdown with a raft of new features including support for HTML, PDF, and Word output, many new options for customizing document appearance, and the ability to create presentations (Beamer or HTML5).
  • Interactive Documents (Shiny meets R Markdown). Readers can now change the parameters underlying your analysis and see the results immediately. Interactive Documents make it easier than ever to use Shiny!
  • Shareable notebooks from R scripts. Notebooks include all R code and generated output, and can be rendered in HTML, PDF, and Word formats.
  • Enhanced debugging including support for the new R 3.1 debugging commands to step into function calls and finish the current loop or function.
  • Various source editor enhancements including new syntax highlighting modes for XML, YAML, SQL, Python, and shell scripts. You can also execute Python and shell scripts directly from the editor using Ctrl+Shift+Enter.
  • Integrated tools for Shiny development including the ability to run applications within an IDE pane as well as Run/Reload applications with a keyboard shortcut (Ctrl+Shift+Enter).
  • A new devtools mode for package development (uses devtools for check, document, test, build, etc.)
  • Contextual Git/SVN menu that enables quick access to per-file revision history and selection-aware View/Blame for projects hosted on GitHub.
  • Fast lookup of shortcuts using the new keyboard shortcut quick-reference card (Alt+Shift+K)

See the release notes for a full list of what’s changed and see Yihui Xie’s post on R Markdown v2 for more on what’s new there.

We’ll be posting additional articles over the next few days that describe the new features in more depth. In the meantime we hope you download the new version and as always let us know how it’s working and what else you’d like to see.

Follow

Get every new post delivered to your Inbox.

Join 688 other followers