R Markdown is one of the more compelling aspects of the R ecosystem, making it easy to incorporate results of R code into a text. Plus, R Markdown files can be exported to a variety of formats—Word, HTML, PDF, PowerPoint, and more. You can even export complete books and websites.

But R Markdown has been around for 10 years. And as more capabilities were added via external R packages, syntax for basic tasks became inconsistent. For example, code to add a document theme depends on whether the output is a stand-alone HTML document, HTML slide presentation, or something else. Plus, while you could run additional languages ​​besides R within an R Markdown code chunk, it still was fundamentally built for R.

Those are two of the reasons RStudio has developed quarto, a next-generation, R Markdown-like publishing system. Quarto is open source, and it’s as friendly to Python, Julia, Observable JavaScript, and Jupyter notebooks as it is to R. It’s not a language-specific library, but an external software application.

Quarto has been publicly available for several months. However, RStudio hasn’t made a formal product announcement yet, and the platform remains in something of a soft launch. In fact, one of the most popular early blog posts about the software was “We don’t talk about Quarto: Until now!” by a former RStudio employee now at IBM, Alison Hill.

However, you can expect Quarto to be a major theme of this year’s RStudio Conference, which starts July 25 in Washington, DC There will be a two-day pre-conference workshop on getting started with Quarto for beginners, a more advanced two-day session for those who want to apply their R Markdown skills in Quarto, and at least half a dozen shorter main conference sessions focusing on Quarto.

There is already some official activity around Quarto on social media including a Quarto Twitter account. And there’s the Quarto Tip a Day blog by Mine Çetinkaya-Rundel, a professor at Duke University who also does work at RStudio.

In case you were wondering, Quarto does not mean the end of R Markdown. “Rest assured #rmarkdown is not going away: We’ll continue to work it! No need to switch #rstats if you don’t need to,” tweeted Christophe Dervieux, a software engineer at RStudio. In fact, most things you know from R Markdown probably can be used in Quarto, if with a bit of tweaking.

So why bother with Quarto?

If you use more than one language, or you are on a multi-language team, you will find Quarto’s native support for multiple languages ​​appealing. The “high internal consistency” is another attraction, as the same syntax will work across more languages ​​and formats.

But one of the most intriguing benefits is down the road. RStudio founder and CEO JJ Allaire envisions cloud-based collaboration for Quarto documents that will work the same way Google Docs editing does now—seamlessly and without users needing to explicitly use an external version control tool like Git. However, Allaire is stressed that this job is not imminent Coding work hadn’t even started on this as of our conversation this week.

For now, though, Quarto was designed to work equally well in Visual Studio Code and Jupyter as it does in RStudio, which the company hopes will make adoption among teams with non-R users more likely. In fact, those doing mostly text work with little code could use a plain text editor for Quarto documents; Rendered HTML documents can be previewed in a browser.

Allaire believes that one of the biggest Quarto advantages is assistance in writing YAML, the language used for both R Markdown and Quarto document header information. YAML can be annoyingly finicky as to where to place colons, commas, and indentations. It’s almost like its own programming language, but without the advantages of an IDE and error-checking. The Quarto editor has built-in YAML assistance. It also aims to highlight errors before you try rendering your document and finding out that it won’t work.

And since Quarto is open source, others can contribute to its functionality by writing extensions. There are several Quarto extensions already available from the Quarto development team.

Another potential advantage, depending on your needs: You can export Quarto documents in more than 40 different file formats including Word, OpenOffice, PowerPoint, ePub, Jira Wiki, Jupyter, Observable JS, complete websites, and ebooks. R Markdown can generate some of those, but not all.

Finally, while R Markdown will be maintained and updated, “[RStudio] will probably not try to backport Quarto features into R Markdown (unless it is fairly straightforward and takes little effort),” RStudio engineer Yihui Xie wrote in a blog post. In other words, cool new features are much more likely to appear in Quarto.

How is Quarto different from R Markdown?

Unlike R Markdown, which is an R package, Quarto is a separate, non-R application. So in order to use Quarto, you will first need to download and install it like you would any other software, in this case from the quarto.org “Get Started” page.

Make sure you have an up-to-date version of RStudio if that’s your IDE, since only more recent versions will run Quarto. For Visual Studio Code, install the VS Code Quarto extension.

If you’ve used R Markdown before, a Quarto document will look familiar. There’s a YAML header with a title, author, and output format. Text uses a lot of generic markdown, such as pound signs for headers and bracket/parenthesis syntax for hyperlinked text: [linked text](https://theurl.com). Both use three backticks to delineate the start and end of code chunks.

Document showing text and R code in RStudio Screenshot by Sharon Machlis

Sample Quarto document in RStudio.

One of the biggest differences between R Markdown and Quarto is how you set up options for code chunks. In R Markdown, chunk-specific options are put within curly braces defining the chunk, such as

```{r chunk_name, echo=FALSE, warning=FALSE}
code here

This creates a block of R code named chunk_name that will be executed, but the code itself won’t display in the rendered document. And any warning messages the code might generate will not appear.

In Quarto, chunk options go below the curly braces. Each option goes on its own line preceded by a pound sign and vertical character, such as

#| label: chunk_name
#| echo: false
#| warning: false

For more details on using Quarto, see the Quarto website. To learn more about the R programming language, head to the Do More With R tutorials page.

Copyright © 2022 IDG Communications, Inc.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *