rstudio/shiny — pull request #485 by yihui (2014-05-16 19:39:43+00:00)
Title: The `width` option for renderPrint()

@wch pointed out that it was not possible to control the width of the `renderPrint()` output, e.g.

```s
runApp(list(
ui = fluidPage(verbatimTextOutput('foo')),
server = function(input, output) {
output$foo = renderPrint({
op = options(width = 30); on.exit(options(op))
mtcars
})
}
))
```

We could set the option before `renderPrint()` and restore it later. However, that will not work in Shiny Docs, e.g.

Print the mtcars data:

```{r test}
op = options(width = 30)
renderPrint(mtcars)
options(op)
```

That is because the actual printing is delayed in knitr in this case: the actual printing occurs after the whole chunk has been evaluated (by that time the `width` has been restored).

These two issues motivated the `width` argument for `renderPrint()`.

Note I removed `withVisible()` in `renderPrint()`, because that has been considered in `capture.output()`, and it seems unnecessary to do it again. Perhaps I missed something there.