These functions work similar to renderText and verbatimTextOutput but will include highlighting with highlight.js and rstudio.css.

renderCode(expr, env = parent.frame(), quoted = FALSE,
  outputArgs = list(), delay = 100)

codeOutput(outputId)

Arguments

expr

An expression that returns an R object that can be used as an argument to cat.

env

The environment in which to evaluate expr.

quoted

Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.

outputArgs

A list of arguments to be passed through to the implicit call to codeOutput when renderCode is used in an interactive R Markdown document.

delay

How much delay to use (in ms) between rendering and firing the syntax highlighting script. For length(delay) > 1 the script will fire multiple times.

outputId

output variable to read the code from.

Examples

if (FALSE) { shinyApp( fluidPage( textAreaInput("code_in", NULL, width = "1000px", height = "200px", paste("f <- function(x) {2*x + 3}", "f(1)", "#> 5", sep = "\n")), codeOutput("code_out") ), function(input, output, session){ output$code_out <- renderCode({ paste(input$code_in) }) } ) }