06 November 2013

Ace Code Editor in Shiny (shinyAce)

The Ace code editor is an elegant, full-featured, browser-based code editor used in such products as RStudio’s IDE. We’re announcing a new R package called shinyAce (now available on CRAN) which integrates the Ace editor into the Shiny web framework.

For those who may be unfamiliar, Shiny is an R package which makes it trivial to create interactive web applications in R — even without knowing any of the languages typically used to create websites (like HTML or JavaScript).

shinyAce exposes all of the color schemes and programming languages (called “modes” in Ace) that Ace supports, meaning you can customize the look and feel of the editor and support syntax highlighting for R, JavaScript, Python, and dozens of other languages. The editor is treated as just another input in Shiny, making it simple to reactively access the text currently contained in the editor. There is also an update function that allows you to update the text (or mode/theme) once the editor has already been created.

See the GitHub page to download the code, view installation instructions, or see details on the examples that come with the package. These examples showe how to create Shiny applications that use shinyAce to allow users to edit and run R code, R Markdown, or even another Shiny user interface.

To install the package:

# Download and install shinyAce

To run an example of shinyAce that features all the available modes and themes on your own machine now:

# Install and load Shiny and ShinyAce

runApp(system.file("examples/01-basic", package="shinyAce"))

You can view a description of all the examples (and instructions for running them) on the GitHub page. Feel free to let us know if you have any issues or feature requests on our Issues page.