You are currently browsing Garrett.Grolemund’s articles.

RStudio is planning a new Master R Developer Workshop to be taught by Hadley Wickham in the San Francisco Bay Area on January 19-20. This will be the same workshop that Hadley is teaching in September in New York City to a sold out audience.

If you did not get a chance to register for the NYC workshop but wished to, consider attending the January Bay Area workshop. We will open registration once we have planned out all of the event details. If you would like to be notified when registration opens, leave a contact address here.

R Markdown is a framework for writing versatile, reproducible reports from R. With R Markdown, you write a simple plain text report and then render it to create polished output. You can:

  1. Transform your file into a pdf, html, or Microsoft Word document—even a slideshow—at the click of a button.
  2. Embed R code into your report. When you render the file, R will run the code and insert its results into your report. Use this feature to add graphs and tables to your report: if your data ever changes, you can update your figures by re-rendering the report.
  3. Make interactive documents and slideshows. Your report becomes interactive when you embed Shiny code.

We’ve created a cheat sheet to help you master R Markdown. Download your copy here. You can also learn more about R Markdown at rmarkdown.rstudio.com and Introduction to R Markdown.

RM-cheatsheet

We’ve added a new section of articles to the Shiny Development Center. These articles explain how to create interactive documents with Shiny and R Markdown.

You’ll learn how to

  • Use R Markdown to create reproducible, dynamic reports. R Markdown offers one of the most efficient workflows for writing up your R results.

  • Create interactive documents and slideshows by embedding Shiny elements into an R Markdown report. The Shiny + R Markdown combo does more than just enhance your reports; R Markdown provides one of the quickest ways to make light weight Shiny apps.

  • Take advantage of RStudio’s built in features that support R Markdown

interactive-articles.001

Learn more at shiny.rstudio.com/articles

RStudio will teach the new essentials for doing data science in R at this year’s Strata NYC conference, Oct 15 2014.

R Day at Strata is a full day of tutorials that will cover some of the most useful topics in R. You’ll learn how to manipulate and visualize data with R, as well as how to write reproducible, interactive reports that foster collaboration. Topics include:

9:00am – 10:30am
A Grammar of Data Manipulation with dplyr
Speaker: Hadley Wickham

11:00am – 12:30pm
A Reactive Grammar of Graphics with ggvis
Speaker: Winston Chang

1:30pm – 3:00pm
Analytic Web Applications with Shiny
Speaker: Garrett Grolemund

3:30pm – 5:00pm
Reproducible R Reports with Packrat and Rmarkdown
Speaker: JJ Allaire & Yihui Xie

The tutorials are integrated into a cohesive day of instruction. Many of the tools that we’ll cover did not exist six months ago, so you are almost certain to learn something new. You will get the most out of the day if you already know how to load data into R and have some basic experience visualizing and manipulating data.

Visit strataconf.com/stratany2014 to learn more and register! Early bird pricing ends July 31.

Not available on October 15? Check out Hadley’s Advanced R Workshop in New York City on September 8 and 9, 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.)

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.

 

We’ve added two new features that make it easier to learn Shiny with the Shiny Dev Center.

  1. Disqus comments – Each lesson and article on the Dev Center now has its own comments section. Use the comments section to start a discussion or to leave feedback about the articles.

  2. How to get help with Shiny – We’ve added a new article, How to get help with Shiny, which explains the best ways to get help with Shiny and R. As an open source language, R doesn’t have a paid support team, which makes getting help with R (and Shiny) a little different than for paid software.

Are you curious about the Shiny Dev Center? The Dev Center is located at shiny.rstudio.com, a central repository of information on Shiny. At the Dev Center, you will find a tutorial, documentation, articles on Shiny, and example Shiny apps.

Shiny apps use an HTML interface, which means that you can change the visual appearance of your apps quickly and simply with CSS files. Would you like to know how? I posted a new article that will step you through the options at the Shiny Dev Center. Check it out here.

Image

We’ve redesigned our training pages to make it even easier for you to learn R or Shiny. Visit our new training web page, www.rstudio.com/training, to see:

  • A curated list of free materials for learning R. We think that these are some of the most helpful resources on the web. They would make an effective starting place if you want to improve your R skills.
  • Announcements for upcoming RStudio public workshops, like the Introduction to R course that we’re holding on April 28 & 29 in San Francisco.
  • A database of well known R instructors, who can provide on-site — as well as online — R training.
  • Links to the new Shiny Dev Center, which includes articles, examples, and a tutorial, all designed to help you master Shiny.
  • Links to the preview sites for R Markdown, an easy option for writing reproducible reports with R, and ggvis, an R package that creates interactive plots with the grammar of graphics.
  • Links to books that we have written (or are writing) about R and its tools.

Why are we so excited about training? We think that learning R and Shiny is the best investment that a data user can make. These two free tools can streamline how you analyze data and deliver results. Browse through the links at www.rstudio.com/training and see for yourself.

 

 

The latest version of lubridate offers some powerful new features and huge speed improvements. Some areas, such as date parsing are more than 50 times faster. lubridate 1.2.0 also fixes those pesky NA bugs in 1.1.0. Here’s some of what you’ll find:

Parsers can now handle a wider variety date formats, even within the same vector

dates <- c("January 31, 2010", "2-28-2010", "03/31/2000")
dates <- mdy(dates)
## [1] "2010-01-31 UTC" "2010-02-28 UTC" "2000-03-31 UTC

Stamp lets you display dates however you like, by emulating an example date

stamper <- stamp("1 March 1999")
stamper(dates)
[1] "31 January 2010"  "28 February 2010" "31 March 2000"

New methods add months without rolling past the end of short months. Its hard to find a satisfactory way to implement addition with months, but the %m+% and %m-% operators provide a new option that wasn’t available before.

ymd("2010-01-31") %m+% months(1:3)
[1] "2010-02-28 UTC" "2010-03-31 UTC" "2010-04-30 UTC"

lubridate 1.2.0 includes many awesome ideas and patches submitted by lubridate users, so check out what is new. For a complete list of new features and contributors, see the package NEWS file on github.

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 653 other followers

RStudio is an affiliated project of the Foundation for Open Access Statistics

Follow

Get every new post delivered to your Inbox.

Join 653 other followers