renderCode: Render code with syntax highlighting

Description Usage Arguments Examples

View source: R/renderCode.R

Description

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

Usage

1
2
3
4
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
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)
    })
  }
)

## End(Not run)

statistikat/codeModules documentation built on Feb. 17, 2021, 11:42 a.m.