mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
add a 'width' argument so we can control the width of the text output
This commit is contained in:
@@ -353,14 +353,15 @@ renderTable <- function(expr, ..., env=parent.frame(), quoted=FALSE, func=NULL)
|
||||
#' @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).
|
||||
#'
|
||||
#' @param width The value for \code{\link{options}('width')}.
|
||||
#' @seealso \code{\link{renderText}} for displaying the value returned from a
|
||||
#' function, instead of the printed output.
|
||||
#'
|
||||
#' @example res/text-example.R
|
||||
#'
|
||||
#' @export
|
||||
renderPrint <- function(expr, env=parent.frame(), quoted=FALSE, func=NULL) {
|
||||
renderPrint <- function(expr, env = parent.frame(), quoted = FALSE, func = NULL,
|
||||
width = getOption('width')) {
|
||||
if (!is.null(func)) {
|
||||
shinyDeprecated(msg="renderPrint: argument 'func' is deprecated. Please use 'expr' instead.")
|
||||
} else {
|
||||
@@ -368,6 +369,8 @@ renderPrint <- function(expr, env=parent.frame(), quoted=FALSE, func=NULL) {
|
||||
}
|
||||
|
||||
markRenderFunction(verbatimTextOutput, function() {
|
||||
op <- options(width = width)
|
||||
on.exit(options(op), add = TRUE)
|
||||
paste(capture.output(func()), collapse = "\n")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
\alias{renderPrint}
|
||||
\title{Printable Output}
|
||||
\usage{
|
||||
renderPrint(expr, env = parent.frame(), quoted = FALSE, func = NULL)
|
||||
renderPrint(expr, env = parent.frame(), quoted = FALSE, func = NULL,
|
||||
width = getOption("width"))
|
||||
}
|
||||
\arguments{
|
||||
\item{expr}{An expression that may print output and/or return a printable R
|
||||
@@ -14,7 +15,9 @@ object.}
|
||||
\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This}
|
||||
|
||||
\item{func}{A function that may print output and/or return a printable R
|
||||
object (deprecated; use \code{expr} instead).}
|
||||
object (deprecated; use \code{expr} instead).}
|
||||
|
||||
\item{width}{The value for \code{\link{options}('width')}.}
|
||||
}
|
||||
\description{
|
||||
Makes a reactive version of the given function that captures any printed
|
||||
|
||||
Reference in New Issue
Block a user