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
install.packages('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
install.packages('shinyAce')
library(shiny)

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.

4 Comments

  1. Tal Galili says:

    VERY interesting work!
    I would love to see a combination of this with swirl:
    http://www.r-bloggers.com/swirl-learning-statistics-r/

    :)

    Tal

  2. Dieter Menne says:

    On Windows:

    > install.packages(‘shinyAce’)
    Installing package into ‘D:/R/R/library’
    (as ‘lib’ is unspecified)

    package ‘shinyAce’ is available as a source package but not as a binary

    Instead, use:

    install.packages(“shinyAce”,type=”source”)

    • Jeff Allen says:

      Sorry about that. It can take a couple of days for the Windows builds to become available on all CRAN mirrors. You can try it again later or install using devtools. The commands for that are available in the GitHub page.

  3. stla says:

    This is a great package. I use it for example to display the code in some pedagogical apps such as http://glimmer.rstudio.com/stla/reactive1/

Trackbacks/Pingbacks

  1. First Public Shiny Example | Type Conversion - [...] is my first use of the shinyAce package. I love it. It’s going to open up a lot of ...
  2. ggplot Live – Show Me Shiny - [...] your ggplot2 code in a live environment, as well as downloadable code and plot files. Uses the shinyAce package ...

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">