File: exprToFunction.Rd

package info (click to toggle)
r-cran-shiny 1.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,080 kB
  • ctags: 290
  • sloc: makefile: 22; sh: 13
file content (61 lines) | stat: -rw-r--r-- 1,616 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{exprToFunction}
\alias{exprToFunction}
\title{Convert an expression to a function}
\usage{
exprToFunction(expr, env = parent.frame(), quoted = FALSE)
}
\arguments{
\item{expr}{A quoted or unquoted expression, or a function.}

\item{env}{The desired environment for the function. Defaults to the
calling environment two steps back.}

\item{quoted}{Is the expression quoted?}
}
\description{
This is to be called from another function, because it will attempt to get
an unquoted expression from two calls back.
}
\details{
If expr is a quoted expression, then this just converts it to a function.
If expr is a function, then this simply returns expr (and prints a
  deprecation message).
If expr was a non-quoted expression from two calls back, then this will
  quote the original expression and convert it to a function.
}
\examples{
# Example of a new renderer, similar to renderText
# This is something that toolkit authors will do
renderTriple <- function(expr, env=parent.frame(), quoted=FALSE) {
  # Convert expr to a function
  func <- shiny::exprToFunction(expr, env, quoted)

  function() {
    value <- func()
    paste(rep(value, 3), collapse=", ")
  }
}


# Example of using the renderer.
# This is something that app authors will do.
values <- reactiveValues(A="text")

\dontrun{
# Create an output object
output$tripleA <- renderTriple({
  values$A
})
}

# At the R console, you can experiment with the renderer using isolate()
tripleA <- renderTriple({
  values$A
})

isolate(tripleA())
# "text, text, text"
}