You are currently browsing jjallaire’s articles.
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;
}
return(mat);
}
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:
sourceCpp("gibbs.cpp")
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) .
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
More
- 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.
RStudio’s mission from the beginning has been to create powerful tools that support the practices and techniques required for creating trustworthy, high quality analysis. For many years Hadley Wickham has been teaching and working on his own set of tools for R with many of the same core goals. We’ve been collaborating quite a bit with Hadley over the past couple of years and today we’re excited to announce that Hadley, Winston Chang, and Garrett Grolemund are joining RStudio so we can continue to work together much more closely.
You probably know Hadley from his work on ggplot2, plyr, and many other packages. Garrett was a PhD student of Hadley’s at Rice, and you might also know him from the lubridate package, which makes dealing with dates and time easier; he’s also been working on new tools for visualisation and new ways of thinking about the process of data analysis. Winston has been working full-time on ggplot2 for the last couple of months, squashing many bugs and repaying a lot of the technical debt that’s accumulated over the years. Winston’s also writing an R Graphics Cookbook for O’Reilly that should be available in the near future.
What does this mean for RStudio? We’ll of course continue developing open-source software like the RStudio IDE, ggplot2, and plyr (among many other projects). One of Hadley’s core focuses at RStudio will also be expanding our mission to include education, which we plan to offer in a variety of formats ranging from in-person training to some innovative new online courses. We’ll also be working on hosted services (like RPubs) as well as some new products that address the challenges of deploying R within larger organizations.
We’re all excited to begin this next phase of work together and will have lots more details to announce later this fall!
Today we’re very excited to announce RPubs, a free service that makes it easy to publish documents to the web from R. RPubs is a quick and easy way to disseminate data analysis and R code and do ad-hoc collaboration with peers.
RPubs documents are based on R Markdown, a new feature of knitr 0.5 and RStudio 0.96. To publish to RPubs within RStudio, you simply create an R Markdown document then click the Publish button within the HTML Preview window:
RPubs documents include a moderated comment stream for feedback and dialog with readers, and can be updated with changes by publishing again from within RStudio.
Note that you’ll only see the Publish button if you update to the latest version of RStudio (v0.96.230, available for download today).
The markdown package
RStudio has integrated support for working with R Markdown and publishing to RPubs, but we also want to make sure that no matter what tools you use it’s still possible to get the same results. To that end we’ve also been working on a new version of the markdown package (v0.5, available now on CRAN).
The markdown package provides a standalone implementation of R Markdown rendering that can be integrated with other editors and IDEs. The package includes a function to upload to RPubs, but is also flexible enough to support lots of other web publishing scenarios. We’ve been working with Jeff Horner on this and he has a more detailed write-up on the capabilities of the markdown package on his blog.
Gallery of examples
We’ve also published a gallery of example documents on RPubs—the gallery illustrates some of the most useful techniques for getting the most out of R Markdown, and includes the following articles:
- MathJax and Writing Equations
- Dynamic Graphics with the googleVis Package
- Customizing Chunk Options
- Caching Code Chunks
Let us know what additional examples you’d like to see—we’ll be adding more in the weeks ahead.
We’ve just a made a change to the syntax for embedding MathJax equations in R Markdown documents. The change was made to eliminate some parsing ambiguities and to support future extensibility to additional formats.
The revised syntax adds a “latex” qualifier to the $ or $$ equation begin delimiter. It looks like this:
This change was the result of a few considerations:
- Some users encountered situations where the $<equation>$ syntax recognized standard text as an equation. There was an escape sequence (\$) to avoid this but for users not explicitly aware of MathJax semantics this was too hard to discover.
- The requirement to have no space between equation delimiters ($) and the equation body (intended to reduce parsing ambiguity) was also confusing for users.
- We want to eventually support ASCIIMath and for this will require an additional qualifier to indicate the equation format.
RStudio v0.96.227 implements the new MathJax syntax and is available for download now.
There’s been lots of excitement about the new R Markdown feature introduced as part of knitr 0.5 and RStudio 0.96. People see R Markdown as both a simpler way to do reproducible research and as a great way to publish to the web from R. Jeromy Anglim has a nice write up on getting started with R Markdown and Marcus Gesmann describes how to embed Google Visualizations using his googleVis package.
We are just as excited about R Markdown and think there is lots more that can be done with it. We’ll be talking about this along with Yihui Xie (author of knitr) and Jeff Horner (author of R/Apache and Rook) on Tuesday June 5th in New York:
http://www.meetup.com/nyhackr/events/64279002/
At the meetup we’ll be showing the latest versions of knitr and RStudio and will be announcing some new R Markdown stuff—if you are in New York we’d love to see you there!
There’s an updated release of RStudio v0.96 available that includes some small enhancements and bugfixes, including:
- Comment/uncomment for Sweave and LaTeX
- Additional in-product documentation for R Markdown
- Offline support for MathJax previews
- More flexible handling of MathJax inline equations
The release notes include a full list all of the changes.
We’ve also published some additional documentation on using the new code folding and code sections features.
The updated version is available for download from our site now.
Today a new version of RStudio (v0.96) is available for download from our website. The main focus of this release is improved tools for authoring, reproducible research, and web publishing. This means lots of new Sweave features as well as tight integration with the knitr package (including support for creating dynamic web reports with the new R Markdown and R HTML formats).
We’ve also added some other frequently requested editing features including code folding. Here’s a short video demo of the new authoring and web publishing features:
We’re particularly excited about the new possibilities opened up by R Markdown, which make it easier than ever to create web content with R. On June 5th in New York we’ll talking about the latest releases of knitr and RStudio with Yihui Xie (knitr) and Jeff Horner (R/Apache and Rook):
http://www.meetup.com/nyhackr/events/64279002/
We’ll also be announcing some more new stuff at the meetup—hope to see you there!
You can download RStudio 0.96 from our website now. Here’s a list of all the new features:
Sweave / knitr
- Spell checking for Sweave and TeX documents.
- Integrated PDF previewer that supports two-way synchronization (SyncTeX) between the editor and PDF view.
- Support for weaving Rnw files using the knitr package (requires knitr version 0.5 or higher).
- Parsing of TeX error logs to extract errors, warnings, and bad boxes and present them in a navigable list.
- Chunk option auto-complete, chunk folding, jump to chunk, and iterative execution of chunks.
- Compilation based on multiple input files (support for specifying a root TeX document) .
- TeX formatting commands, block comment/uncomment, and various new compilation options.
Web Publishing
- Editing and previewing R Markdown and R HTML files (like Sweave except for web pages).
- Creation of easy to distribute standalone HTML files (with embedded images).
- Support for including LaTeX, ASCIIMath, and MathML equations in web pages using MathJax.
Source Editing
- Find in files with regular expressions.
- Code folding (expanding and collapsing regions of code).
- Automatic comment reflowing (Cmd+Shift+/).
- Smart editing of Roxygen comments.
- Syntax highlighting for Markdown, HTML, Javascript, and CSS files.
- New font customization options.
Miscellaneous
- Fixed incompatibility with Winbind for PAM authentication.
- Fixed editor cursor off by one line problem that occurred after rapid scrolling.
The final version of RStudio v0.95 is now available for download from our website (thanks to everyone who put the preview release through its paces over the last couple of weeks!). Highlights of the new release include:
- Projects — A new system for managing R projects that enables easy switching between working directories and per-project contexts for source documents, workspaces, and history.
- Code Navigation — Typeahead navigation by file or function name (Ctrl+.) and the ability to navigate directly to the definition of any function (F2 or Ctrl+Click).
- Version Control — Integrated support for Git and Subversion, including changelist management, diffing/staging, and project history.
Quite a bit has been added to RStudio since the initial v0.92 release a year ago. We’ve put together a new screencast that includes a quick tour of the product and also highlights some of the new features in v0.95:
There is also an interview with RStudio founder JJ Allaire over on DecisionStats that has a more in-depth discussion of the release and the RStudio project in general.
The evolution of RStudio is a direct result of the many in-depth conversations we’ve had with users at meetups, conferences, and on our support forum. We realize that there’s plenty more to do and hope we can keep up with all of the great feedback! In that spirit we hope to see lots of folks this Thursday night at the Chicago RUG meetup as well as in February in Houston and Los Angeles.
The next version of RStudio (v0.95) is now available as a preview release. Highlights include:
- Projects — A new system for managing R projects that enables easy switching between working directories, running multiple instances of RStudio with different projects, and per-project contexts for source documents, workspaces, and history.
- Code Navigation — Typeahead navigation by file or function name (Ctrl+.) and the ability to navigate directly to the definition of any function (F2 or Ctrl+Click).
- Version Control — Integrated support for Git and Subversion, including changelist management, diffing/staging, and project history.
Detailed documentation on the new features will be available along with the final release of v0.95, which we expect to make available by the end of January.
We’re also planning on being at the Chicago, Houston, and Los Angeles R User Groups over the next few weeks. We’ll be talking about the new release as well as the general state of the project and where people would like to see us go in the future. Meeting dates are:
- Chicago (Thursday, January 26th)
- Houston (Tuesday, February 7th)
- Los Angeles (Thursday, February 9th)
Thanks in advance to everyone who tries out the preview release (you can download it here). Let us know what works, what doesn’t, and what else you’d like to see us do.







