You are currently browsing the monthly archive for November 2012.

Earlier this month a new version of the Rcpp package by Dirk Eddelbuettel and Romain François  was released to CRAN and today we’re excited to announce a new version of RStudio that integrates tightly with Rcpp.

First though more about some exciting new features in Rcpp 0.10.1. This release includes Rcpp attributes, which are simple annotations that you add to C++ source files to streamline calling C++ from R.  This makes it possible to write C++ functions and simply source them into R just as you’d source an R script. Here’s an example:

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
NumericMatrix gibbs(int N, int thin) {

   NumericMatrix mat(N, 2);
   double x = 0, y = 0;

   RNGScope scope;
   for(int i = 0; i < N; i++) {
      for(int j = 0; j < thin; j++) {
         x = R::rgamma(3.0, 1.0 / (y * y + 4));
         y = R::rnorm(1.0 / (x + 1), 1.0 / sqrt(2 * x + 2));
      mat(i, 0) = x;
      mat(i, 1) = y;


By annotating the gibbs function with the Rcpp::export attribute, we indicate we’d like that function to be callable from R. As a result we can now call the function like this:

gibbs(100, 10)

Thanks to the abstractions provided by Rcpp, the code implementing gibbs in C++ is nearly identical to the code you’d write in R, but runs 20 times faster.

The sourceCpp function makes it much easier to use C++ within interactive R sessions. In the new version of RStudio we did a few things to support this workflow. Here’s a screenshot showing the RStudio C++ editing mode:

In RStudio you can now source a C++ file in the same way as an R script, using the source button on the toolbar or Cmd+Shift+Enter. If errors occur during compilation then RStudio parses the GCC error log and presents the errors as a navigable list.

When using sourceCpp it’s also possible to embed R code within a C++ source file using a special block comment. RStudio treats this code as an R code chunk (similar to Sweave or R Markdown code chunks):

RStudio also includes extensive support for package development with Rcpp. For more details see the Using Rcpp with RStudio document on our website.

Note that if you want to try out the new features be sure you are running RStudio v0.97.237 as well as the very latest version of Rcpp (0.10.1) .

Say hello to Shiny, a new R package that we’re releasing for public beta testing today.

Shiny makes it super simple for R users to turn analyses into interactive web applications that anyone can use. These applications let you specify input parameters using friendly controls like sliders, drop-downs, and text fields; and they can easily incorporate any number of outputs like plots, tables, and summaries.

No HTML or JavaScript knowledge is necessary. If you have some experience with R, you’re just minutes away from combining the statistical power of R with the simplicity of a web page:

Shiny application screenshot

More details, including live examples and a link to an extensive tutorial, can be found on the Shiny homepage.

The Shiny package is free and open source, and is designed primarily to run Shiny applications locally. To share Shiny applications with others, you can send them your application source as a GitHub gist, R package, or zip file (see details). We’re also working on a Shiny server that is designed to provide enterprise-grade application hosting, which we’ll offer as a subscription-based hosting service and/or commercial software package.

We’re really excited about Shiny, and look forward to seeing what kind of applications you come up with!

(Special thanks to Bryan Lewis for authoring the websockets package, which is used heavily by Shiny.)

Shiny homepage

Today a new version of RStudio (v0.97) is available for download from our website.  The principal focus of this release was creating comprehensive tools for R package development. We also implemented many other frequently requested enhancements including a new Vim editing mode and a much improved Find and Replace pane. Here’s a summary of what’s new in the release:

Package Development

  • A new Build tab with package development commands and a view of build output and errors
  • Build and Reload command that rebuilds the package and reloads it in a fresh R session
  • Create a new package using existing source files via New Project
  • R documentation tools including previewing, spell-checking, and Roxygen aware editing
  • Integration with devtools package development functions
  • Support for Rcpp including syntax highlighting for C/C++ and gcc error navigation

Source Editor

  • Vim editing mode
  • Tomorrow suite of editor themes
  • Find and replace: incremental search, find/replace in selection, and backwards find
  • Auto-indenting: improved intelligence and new options to customize indenting behavior
  • New options: show whitespace, show indent guides, non-blinking cursor, focus console after executing code


  • New Restart R and Terminate R commands
  • More intelligent console history navigation with up/down arrow keys
  • View plots within a separate window/monitor.
  • Ability to set a global UI zoom-level
  • RStudio CRAN mirror (via Amazon CloudFront) for fast package downloads

There are also many more small improvements and bug fixes. Check out the v0.97 release notes for details on all of the changes.

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

Join 518 other followers

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


Get every new post delivered to your Inbox.

Join 518 other followers