Update documentation for renderXX

This commit is contained in:
Winston Chang
2013-02-12 16:59:07 -06:00
parent e26f175a8f
commit e406a76b62
18 changed files with 130 additions and 272 deletions

View File

@@ -60,7 +60,12 @@ export(plotOutput)
export(pre)
export(radioButtons)
export(reactive)
export(reactivePlot)
export(reactivePrint)
export(reactiveTable)
export(reactiveText)
export(reactiveTimer)
export(reactiveUI)
export(reactiveValues)
export(reactiveValuesToList)
export(renderPlot)

View File

@@ -708,7 +708,7 @@ tabsetPanel <- function(..., id = NULL) {
#' @param outputId output variable to read the value from
#' @return A text output element that can be included in a panel
#' @details Text is HTML-escaped prior to rendering. This element is often used
#' to dispaly \link{renderText} output variables.
#' to display \link{renderText} output variables.
#' @examples
#' h3(textOutput("caption"))
#' @export

View File

@@ -507,7 +507,7 @@ Observer <- setRefClass(
#'
#' # In a normal Shiny app, the web client will trigger flush events. If you
#' # are at the console, you can force a flush with flushReact()
#' flushReact()
#' shiny:::flushReact()
#'
#' @export
observe <- function(x, env=parent.frame(), quoted=FALSE, label=NULL,

View File

@@ -5,7 +5,7 @@ suppressPackageStartupMessages({
#' Plot Output
#'
#' Creates a reactive plot that is suitable for assigning to an \code{output}
#' Renders a reactive plot that is suitable for assigning to an \code{output}
#' slot.
#'
#' The corresponding HTML output tag should be \code{div} or \code{img} and have
@@ -17,7 +17,7 @@ suppressPackageStartupMessages({
#' output. Notably, plain \code{png} output on Linux and Windows may not
#' antialias some point shapes, resulting in poor quality output.
#'
#' @param func A function that generates a plot.
#' @param expr An expression that generates a plot.
#' @param width The width of the rendered plot, in pixels; or \code{'auto'} to
#' use the \code{offsetWidth} of the HTML element that is bound to this plot.
#' You can also pass in a function that returns the width in pixels or
@@ -30,6 +30,11 @@ suppressPackageStartupMessages({
#' values and functions.
#' @param ... Arguments to be passed through to \code{\link[grDevices]{png}}.
#' These can be used to set the width, height, background color, etc.
#' @param env The environment in which to evaluate \code{expr}.
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
#' is useful if you want to save an expression in a variable.
#' @param func A function that generates a plot (deprecated; use \code{expr}
#' instead).
#'
#' @export
renderPlot <- function(expr, width='auto', height='auto', ...,
@@ -110,10 +115,15 @@ renderPlot <- function(expr, width='auto', height='auto', ...,
#' The corresponding HTML output tag should be \code{div} and have the CSS class
#' name \code{shiny-html-output}.
#'
#' @param func A function that returns an R object that can be used with
#' @param expr An expression that returns an R object that can be used with
#' \code{\link[xtable]{xtable}}.
#' @param ... Arguments to be passed through to \code{\link[xtable]{xtable}} and
#' \code{\link[xtable]{print.xtable}}.
#' @param env The environment in which to evaluate \code{expr}.
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
#' is useful if you want to save an expression in a variable.
#' @param func A function that returns an R object that can be used with
#' \code{\link[xtable]{xtable}} (deprecated; use \code{expr} instead).
#'
#' @export
renderTable <- function(expr, ..., env=parent.frame(), quoted=FALSE, func=NULL) {
@@ -160,8 +170,12 @@ renderTable <- function(expr, ..., env=parent.frame(), quoted=FALSE, func=NULL)
#' returns \code{NULL} then \code{NULL} will actually be visible in the output.
#' To display nothing, make your function return \code{\link{invisible}()}.
#'
#' @param func A function that may print output and/or return a printable R
#' @param expr An expression that may print output and/or return a printable R
#' object.
#' @param env The environment in which to evaluate \code{expr}.
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
#' @param func A function that may print output and/or return a printable R
#' object (deprecated; use \code{expr} instead).
#'
#' @seealso \code{\link{renderText}} for displaying the value returned from a
#' function, instead of the printed output.
@@ -198,8 +212,13 @@ renderPrint <- function(expr, env=parent.frame(), quoted=FALSE, func=NULL) {
#' The result of executing \code{func} will passed to \code{cat}, inside a
#' \code{\link[utils]{capture.output}} call.
#'
#' @param func A function that returns an R object that can be used as an
#' @param expr An expression that returns an R object that can be used as an
#' argument to \code{cat}.
#' @param env The environment in which to evaluate \code{expr}.
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
#' is useful if you want to save an expression in a variable.
#' @param func A function that returns an R object that can be used as an
#' argument to \code{cat}.(deprecated; use \code{expr} instead).
#'
#' @seealso \code{\link{renderPrint}} for capturing the print output of a
#' function, rather than the returned text value.
@@ -228,8 +247,13 @@ renderText <- function(expr, env=parent.frame(), quoted=FALSE, func=NULL) {
#' The corresponding HTML output tag should be \code{div} and have the CSS class
#' name \code{shiny-html-output} (or use \code{\link{uiOutput}}).
#'
#' @param func A function that returns a Shiny tag object, \code{\link{HTML}},
#' @param expr An expression that returns a Shiny tag object, \code{\link{HTML}},
#' or a list of such objects.
#' @param env The environment in which to evaluate \code{expr}.
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
#' is useful if you want to save an expression in a variable.
#' @param func A function that returns a Shiny tag object, \code{\link{HTML}},
#' or a list of such objects (deprecated; use \code{expr} instead).
#'
#' @seealso conditionalPanel
#'
@@ -307,22 +331,56 @@ downloadHandler <- function(filename, content, contentType=NA) {
# Deprecated functions ------------------------------------------------------
#' Plot output (deprecated)
#'
#' See \code{\link{renderPlot}}.
#' @param func A function.
#' @param width Width.
#' @param height Height.
#' @param ... Other arguments to pass on.
#' @export
reactivePlot <- function(func, width='auto', height='auto', ...) {
shinyDeprecated(new="renderPlot")
renderPlot({ func() }, width='auto', height='auto', ...)
}
#' Table output (deprecated)
#'
#' See \code{\link{renderTable}}.
#' @param func A function.
#' @param ... Other arguments to pass on.
#' @export
reactiveTable <- function(func, ...) {
shinyDeprecated(new="renderTable")
renderTable({ func() })
}
#' Print output (deprecated)
#'
#' See \code{\link{renderPrint}}.
#' @param func A function.
#' @export
reactivePrint <- function(func) {
shinyDeprecated(new="renderPrint")
renderPrint({ func() })
}
#' UI output (deprecated)
#'
#' See \code{\link{renderUI}}.
#' @param func A function.
#' @export
reactiveUI <- function(func) {
shinyDeprecated(new="renderUI")
renderUI({ func() })
}
#' Text output (deprecated)
#'
#' See \code{\link{renderText}}.
#' @param func A function.
#' @export
reactiveText <- function(func) {
shinyDeprecated(new="renderText")
renderText({ func() })

View File

@@ -21,8 +21,8 @@
}
\details{
\code{uiOutput} is intended to be used with
\code{reactiveUI} on the server side. It is currently
just an alias for \code{htmlOutput}.
\code{renderUI} on the server side. It is currently just
an alias for \code{htmlOutput}.
}
\examples{
htmlOutput("summary")

View File

@@ -63,6 +63,6 @@ obsD <- observe(expr_q, quoted = TRUE)
# In a normal Shiny app, the web client will trigger flush events. If you
# are at the console, you can force a flush with flushReact()
flushReact()
shiny:::flushReact()
}

View File

@@ -18,7 +18,7 @@
A plot output element that can be included in a panel
}
\description{
Render a \link{reactivePlot} within an application page.
Render a \link{renderPlot} within an application page.
}
\examples{
# Show a plot of the generated distribution

View File

@@ -1,45 +1,19 @@
\name{reactivePlot}
\alias{reactivePlot}
\title{Plot Output}
\title{Plot output (deprecated)}
\usage{
reactivePlot(func, width = "auto", height = "auto", ...)
}
\arguments{
\item{func}{A function that generates a plot.}
\item{func}{A function.}
\item{width}{The width of the rendered plot, in pixels;
or \code{'auto'} to use the \code{offsetWidth} of the
HTML element that is bound to this plot. You can also
pass in a function that returns the width in pixels or
\code{'auto'}; in the body of the function you may
reference reactive values and functions.}
\item{width}{Width.}
\item{height}{The height of the rendered plot, in pixels;
or \code{'auto'} to use the \code{offsetHeight} of the
HTML element that is bound to this plot. You can also
pass in a function that returns the width in pixels or
\code{'auto'}; in the body of the function you may
reference reactive values and functions.}
\item{height}{Height.}
\item{...}{Arguments to be passed through to
\code{\link[grDevices]{png}}. These can be used to set
the width, height, background color, etc.}
\item{...}{Other arguments to pass on.}
}
\description{
Creates a reactive plot that is suitable for assigning to
an \code{output} slot.
}
\details{
The corresponding HTML output tag should be \code{div} or
\code{img} and have the CSS class name
\code{shiny-plot-output}.
For output, it will try to use the following devices, in
this order: quartz (via \code{\link[grDevices]{png}}),
then \code{\link[Cairo]{CairoPNG}}, and finally
\code{\link[grDevices]{png}}. This is in order of quality
of output. Notably, plain \code{png} output on Linux and
Windows may not antialias some point shapes, resulting in
poor quality output.
See \code{\link{renderPlot}}.
}

View File

@@ -1,101 +1,13 @@
\name{reactivePrint}
\alias{reactivePrint}
\title{Printable Output}
\title{Print output (deprecated)}
\usage{
reactivePrint(func)
}
\arguments{
\item{func}{A function that may print output and/or
return a printable R object.}
\item{func}{A function.}
}
\description{
Makes a reactive version of the given function that
captures any printed output, and also captures its
printable result (unless \code{\link{invisible}}), into a
string. The resulting function is suitable for assigning
to an \code{output} slot.
}
\details{
The corresponding HTML output tag can be anything (though
\code{pre} is recommended if you need a monospace font
and whitespace preserved) and should have the CSS class
name \code{shiny-text-output}.
The result of executing \code{func} will be printed
inside a \code{\link[utils]{capture.output}} call.
Note that unlike most other Shiny output functions, if
the given function returns \code{NULL} then \code{NULL}
will actually be visible in the output. To display
nothing, make your function return
\code{\link{invisible}()}.
}
\examples{
isolate({
# reactivePrint captures any print output, converts it to a string, and
# returns it
visFun <- reactivePrint(function() "foo")
visFun()
# '[1] "foo"'
invisFun <- reactivePrint(function() invisible("foo"))
invisFun()
# ''
multiprintFun <- reactivePrint(function() {
print("foo");
"bar"
})
multiprintFun()
# '[1] "foo"\\n[1] "bar"'
nullFun <- reactivePrint(function() NULL)
nullFun()
# 'NULL'
invisNullFun <- reactivePrint(function() invisible(NULL))
invisNullFun()
# ''
vecFun <- reactivePrint(function() 1:5)
vecFun()
# '[1] 1 2 3 4 5'
# Contrast with reactiveText, which takes the value returned from the function
# and uses cat() to convert it to a string
visFun <- reactiveText(function() "foo")
visFun()
# 'foo'
invisFun <- reactiveText(function() invisible("foo"))
invisFun()
# 'foo'
multiprintFun <- reactiveText(function() {
print("foo");
"bar"
})
multiprintFun()
# 'bar'
nullFun <- reactiveText(function() NULL)
nullFun()
# ''
invisNullFun <- reactiveText(function() invisible(NULL))
invisNullFun()
# ''
vecFun <- reactiveText(function() 1:5)
vecFun()
# '1 2 3 4 5'
})
}
\seealso{
\code{\link{reactiveText}} for displaying the value
returned from a function, instead of the printed output.
See \code{\link{renderPrint}}.
}

View File

@@ -1,23 +1,15 @@
\name{reactiveTable}
\alias{reactiveTable}
\title{Table Output}
\title{Table output (deprecated)}
\usage{
reactiveTable(func, ...)
}
\arguments{
\item{func}{A function that returns an R object that can
be used with \code{\link[xtable]{xtable}}.}
\item{func}{A function.}
\item{...}{Arguments to be passed through to
\code{\link[xtable]{xtable}} and
\code{\link[xtable]{print.xtable}}.}
\item{...}{Other arguments to pass on.}
}
\description{
Creates a reactive table that is suitable for assigning
to an \code{output} slot.
}
\details{
The corresponding HTML output tag should be \code{div}
and have the CSS class name \code{shiny-html-output}.
See \code{\link{renderTable}}.
}

View File

@@ -1,95 +1,13 @@
\name{reactiveText}
\alias{reactiveText}
\title{Text Output}
\title{Text output (deprecated)}
\usage{
reactiveText(func)
}
\arguments{
\item{func}{A function that returns an R object that can
be used as an argument to \code{cat}.}
\item{func}{A function.}
}
\description{
Makes a reactive version of the given function that also
uses \code{\link[base]{cat}} to turn its result into a
single-element character vector.
}
\details{
The corresponding HTML output tag can be anything (though
\code{pre} is recommended if you need a monospace font
and whitespace preserved) and should have the CSS class
name \code{shiny-text-output}.
The result of executing \code{func} will passed to
\code{cat}, inside a \code{\link[utils]{capture.output}}
call.
}
\examples{
isolate({
# reactivePrint captures any print output, converts it to a string, and
# returns it
visFun <- reactivePrint(function() "foo")
visFun()
# '[1] "foo"'
invisFun <- reactivePrint(function() invisible("foo"))
invisFun()
# ''
multiprintFun <- reactivePrint(function() {
print("foo");
"bar"
})
multiprintFun()
# '[1] "foo"\\n[1] "bar"'
nullFun <- reactivePrint(function() NULL)
nullFun()
# 'NULL'
invisNullFun <- reactivePrint(function() invisible(NULL))
invisNullFun()
# ''
vecFun <- reactivePrint(function() 1:5)
vecFun()
# '[1] 1 2 3 4 5'
# Contrast with reactiveText, which takes the value returned from the function
# and uses cat() to convert it to a string
visFun <- reactiveText(function() "foo")
visFun()
# 'foo'
invisFun <- reactiveText(function() invisible("foo"))
invisFun()
# 'foo'
multiprintFun <- reactiveText(function() {
print("foo");
"bar"
})
multiprintFun()
# 'bar'
nullFun <- reactiveText(function() NULL)
nullFun()
# ''
invisNullFun <- reactiveText(function() invisible(NULL))
invisNullFun()
# ''
vecFun <- reactiveText(function() 1:5)
vecFun()
# '1 2 3 4 5'
})
}
\seealso{
\code{\link{reactivePrint}} for capturing the print
output of a function, rather than the returned text
value.
See \code{\link{renderText}}.
}

View File

@@ -1,33 +1,13 @@
\name{reactiveUI}
\alias{reactiveUI}
\title{UI Output}
\title{UI output (deprecated)}
\usage{
reactiveUI(func)
}
\arguments{
\item{func}{A function that returns a Shiny tag object,
\code{\link{HTML}}, or a list of such objects.}
\item{func}{A function.}
}
\description{
\bold{Experimental feature.} Makes a reactive version of
a function that generates HTML using the Shiny UI
library.
}
\details{
The corresponding HTML output tag should be \code{div}
and have the CSS class name \code{shiny-html-output} (or
use \code{\link{uiOutput}}).
}
\examples{
\dontrun{
output$moreControls <- reactiveUI(function() {
list(
)
})
}
}
\seealso{
conditionalPanel
See \code{\link{renderUI}}.
}

20
man/shinyDeprecated.Rd Normal file
View File

@@ -0,0 +1,20 @@
\name{shinyDeprecated}
\alias{shinyDeprecated}
\title{Print message for deprecated functions in Shiny}
\usage{
shinyDeprecated(new = NULL, msg = NULL,
old = as.character(sys.call(sys.parent()))[1L])
}
\arguments{
\item{new}{Name of replacement function.}
\item{msg}{Message to print. If used, this will override
the default message.}
\item{old}{Name of deprecated function.}
}
\description{
To disable these messages, use
\code{options(shiny.deprecation.messages=FALSE)}.
}

View File

@@ -32,7 +32,7 @@
# A very simple Shiny app that takes a message from the user
# and outputs an uppercase version of it.
shinyServer(function(input, output) {
output$uppercase <- reactiveText(function() {
output$uppercase <- renderText({
toupper(input$message)
})
})

View File

@@ -11,7 +11,7 @@
A table output element that can be included in a panel
}
\description{
Render a \link{reactiveTable} within an application page.
Render a \link{renderTable} within an application page.
}
\examples{
mainPanel(

View File

@@ -17,8 +17,7 @@
}
\details{
Text is HTML-escaped prior to rendering. This element is
often used to dispaly \link{reactiveText} output
variables.
often used to display \link{renderText} output variables.
}
\examples{
h3(textOutput("caption"))

View File

@@ -18,7 +18,7 @@
}
\details{
Text is HTML-escaped prior to rendering. This element is
often used with the \link{reactivePrint} function to
often used with the \link{renderPrint} function to
preserve fixed-width formatting of printed objects.
}
\examples{

View File

@@ -2,60 +2,60 @@ isolate({
# renderPrint captures any print output, converts it to a string, and
# returns it
visFun <- renderPrint(function() "foo")
visFun <- renderPrint({ "foo" })
visFun()
# '[1] "foo"'
invisFun <- renderPrint(function() invisible("foo"))
invisFun <- renderPrint({ invisible("foo") })
invisFun()
# ''
multiprintFun <- renderPrint(function() {
multiprintFun <- renderPrint({
print("foo");
"bar"
})
multiprintFun()
# '[1] "foo"\n[1] "bar"'
nullFun <- renderPrint(function() NULL)
nullFun <- renderPrint({ NULL })
nullFun()
# 'NULL'
invisNullFun <- renderPrint(function() invisible(NULL))
invisNullFun <- renderPrint({ invisible(NULL) })
invisNullFun()
# ''
vecFun <- renderPrint(function() 1:5)
vecFun <- renderPrint({ 1:5 })
vecFun()
# '[1] 1 2 3 4 5'
# Contrast with renderText, which takes the value returned from the function
# and uses cat() to convert it to a string
visFun <- renderText(function() "foo")
visFun <- renderText({ "foo" })
visFun()
# 'foo'
invisFun <- renderText(function() invisible("foo"))
invisFun <- renderText({ invisible("foo") })
invisFun()
# 'foo'
multiprintFun <- renderText(function() {
multiprintFun <- renderText({
print("foo");
"bar"
})
multiprintFun()
# 'bar'
nullFun <- renderText(function() NULL)
nullFun <- renderText({ NULL })
nullFun()
# ''
invisNullFun <- renderText(function() invisible(NULL))
invisNullFun <- renderText({ invisible(NULL) })
invisNullFun()
# ''
vecFun <- renderText(function() 1:5)
vecFun <- renderText({ 1:5 })
vecFun()
# '1 2 3 4 5'